Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

Default values for primitives and references

Type Default Value booleanfalse byte0 short0 int0 long0L char\u0000 float0.0f double0.0d object referencenull public class ClassInitializer1 {   static boolean bool;   static byte by;   static char ch;   static double d;   static float f;   static int i;   static long l;   static short sh;   static String str;   public static void main(String[] args) {     System.out.println("bool = " + bool);     System.out.println("by = " + by);     System.out.println("ch = " + ch);     System.out.println("d = " + d);     System.out.println("f = " + f);     System.out.println("i = " + i);     System.out.println("l = " + l);     System.out.println("sh = " + sh);     System.out.println("str = " + str);   } }