Choose Your Language

Sunday, 14 July 2013

java program to find default value of java primitive data types

public class DataTypeDefaultSize {   
     byte  b;
     boolean boo;
     char c;
     short s;
     int i ;
     long l;
     float f;     
     double d;        
     public static void main(String a[]) {
        DataTypeDefaultSize dataTypeDefaultSize=new DataTypeDefaultSize();
        dataTypeDefaultSize.displayDataTypeDefaultSize();
     }
     void displayDataTypeDefaultSize(){
         System.out.println("default value of byte is "+b);
         System.out.println("default value of boolean is "+boo); 
         System.out.println("default value of char is "+c);
         System.out.println("default value of short is "+s);
         System.out.println("default value of int is "+i);
         System.out.println("default value of long is "+l);
         System.out.println("default value of float is "+f);        
         System.out.println("default value of double is "+d);
       
     }
}


output:
default value of byte is 0
default value of boolean is false
default value of char is
default value of short is 0
default value of int is 0
default value of long is 0
default value of float is 0.0
default value of double is 0.0




No comments:

Post a Comment