Java Basics - Lecture 1 - What is Java

The Hacks of The Day















In this session, we will cover Java basics. To learn selenium it is very important to learn Java. Without Java, you can not learn Selenium. Although many other languages are available that are supported by Selenium Selenium with Java is the best combination. 90% of companies use this combination. If you have manual testing the background then these videos are very helpful for you to learn Java basics, not advanced Java. To learn Selenium only core Java basics are required not advanced Java. We will cover the following topics:

Lecture 1 Agenda:

  1. What is Java
  2. What is Eclipse
  3. Data types in Java
  4. What is System.out.println() and System.out.print()

1) What is Java?

- A computer programming language.
- Open source technology (License free)
- No paid license required
- A high-level of language
- Pure object-oriented programming language
- Developed by Sun Microsystems
- OS/Platform independent

2) What is Eclipse?

- IDE(Integrated Development Environment)/Editor
- Open source, free to use
- Used for Java development
- Although we can use it for other languages
- But purely used for Java
- Flexible for Plugins (Junit, TestNG, Maven)
- Easy to use and very user friendly

3) Data Types

- How you are representing your data
- Int, String, Character, Boolean, Double, Long

Integer

     int I = 10;
     int j = 30;
     int l = -1;
     int k = 40;

- Duplicate variables are not allowed
- The variable should be unique
- Every statement should be ended with semicolon

Double

     double d1 = 24.7;
     double d2 = 44.56;
     double d3 = 100;

Character

- character is an only single-digit value
- Should be written in single quotes

     char c = 'a'
     char d = 'b';

Boolean

     boolean b1 = true;
     boolean b2 = false;

String

- The string is a class, not a data type
- But can be used as a data type
- String s = “Hello world”;
- It is always written in double quotes
   
     String s1 = "Selenium";
     String s2 = "Java Test code";
     String s3 = "100";
     String s4 = "12.33";

- Primitive data types (int, char, boolean, double)
- Warnings are shown when a variable is declared but not used

What is System.out.println() and System.out.print()

- println() method prints the output and moves the cursor to a new line.
- Each output will be printed on a new line
- print() method prints the all output in one line