|
| |
| 2. 1. 3. Default values for primitives and references |
|
|
| Type | Default Value | | boolean | false | | byte | 0 | | short | 0 | | int | 0 | | long | 0L | | char | \u0000 | | float | 0.0f | | double | 0.0d | | object reference | null |
|
|
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);
}
}
|
|
|