Java Tutorials For Selenium-2.0

Data types in Java :

There are 8 different data types in java like : byte, short, int, long, float, double, char, boolean.

int datatype : int data type is useful to store 32 bit integer (Example : 4523) values only. We can not store decimal (Example 452.23) values in int data type.

Example : 

int i = 4523;
long datatype : long datatype is useful to store 64 bit integer(Example : 652345) values. You can use it when your value is more larger and can not hold it in int. Same as int datatype, we can not store decimal (Example 452.23) values in long datatype

Example : 

long l = 652345;

double datatype : double datatype is useful to store 64 bit decimal(Example : 56.2354) values. We can store integer (Example 12456) values too in double datatype.

Example : 

double d1 = 56.2354;

double d2 = 12456;

char datatype : char datatype is useful to store single character(Example : ‘d’). It can not store more than one (Example ‘dd’) character in it.

Example : 

char c = 'd';


boolean datatype : boolean datatype is useful to store only boolean(Example : true) values.
Example : 

boolean b = true;

String Class
String is not a data type but it is a class which is useful to store string in variable.
Example :

String str = "Hello World";

 

Author:

Girija