Data Type Examples
Example of Primitive Data Type
Example of Primitive Data Type
public class DataType
{
public static void main(String[] args)
{
float f = 10.0f; //float
double d = 100000.00; //double
char c = 'S'; //char
String s = "Techknow"; //String
long l = 2456L;
int i= 102;//long
System.out.println("float:-"+f);
System.out.println("double:-"+c);
System.out.println("char:-"+d);
System.out.println("long:-"+l);
System.out.println("string:-"+s);
}
}
Output
float:-10.0 double:-100000.0 char:-S long:-2456 string:-Techknow
Example of Reference Types
Reference Types
public class RefType
{
public static void main(String agr[])
{
String a = new String ("Hello");
String b= new String ("Hello");
String c = a;
if(a==c)
{
System.out.println("Same Ref ");
}
else
{
System.out.println("Not Same Ref ");
}
}
}
Output
Same Ref


