Automatic Initialization/Default Values for Primitive Types : Primitive Data Types « Java Source And Data Type « SCJP






Type           Default Value

boolean        false

byte           0

char           \u0000

short          0

int            0

long           0L

float          0.0f

double         0.0d


public class MainClass {
  boolean bo;

  byte by;

  char c;

  short s;

  int i;

  long l;

  float f;

  double d;

  Object o;

  public static void main(String[] args) {
    MainClass app = new MainClass();
    app.run();
  }

  void run() {
    int[] intArray = new int[2];
    Object[] objectArray = new Object[2];
    System.out.println("boolean: " + bo);
    System.out.println("byte: " + by);
    System.out.println("char: " + c);
    System.out.println("short: " + s);
    System.out.println("int: " + i);
    System.out.println("long: " + l);
    System.out.println("float: " + f);
    System.out.println("double: " + d);
    System.out.println("Object: " + o);
    System.out.println("int[2]: " + intArray[0] + " " + intArray[1]);
    System.out.println("Object[2]: " + objectArray[0] + " " + objectArray[1]);
  }
}
boolean: false
byte: 0
char: 
short: 0
int: 0
long: 0
float: 0.0
double: 0.0
Object: null
int[2]: 0 0
Object[2]: null null








1.8.Primitive Data Types
1.8.1.Primitive Data Types are simple non-object data types.
1.8.2.You can declare one or more primitives, of the same primitive type, in a single line.
1.8.3.Ranges(Effective Sizes) of Numeric Primitives. The positive range is one less than the negative range.
1.8.4.Java integer primitives are always signed except for the char primitive type.
1.8.5.Automatic Initialization/Default Values for Primitive Types