Wednesday, 27 December 2017

1.3 Variables and Datatype

Variable : A variable is a named storage location where you can store different values.

Primitive variables : int, float, double, long, char , byte , boolean 

Datatype : Type of data store in a variable is called datatype



You can't store large value in small variable.


Different types of variable with their size and default values



class Add
{
public static void main(String args[])
{
System.out.println(1+2);

int a=3;
int b=5;
System.out.println(a+b);

float p=3.4f;
float q=3.5f;
System.out.println(p+q);

char j='A';
System.out.println(j);
System.out.println((int)j);

int t=78;
System.out.println(t);
System.out.println((char)t);
}
}



Precision

No comments:

Post a Comment