Shows default initial values : Data Type Introduction « Data Type « Java Tutorial






public class MainClass {
  boolean t;

  char c;

  byte b;

  short s;

  int i;

  long l;

  float f;

  double d;

  void print(String s) {
    System.out.println(s);
  }

  void printInitialValues() {
    print("Data type      Initial value");
    print("boolean        " + t);
    print("char           [" + c + "]");
    print("byte           " + b);
    print("short          " + s);
    print("int            " + i);
    print("long           " + l);
    print("float          " + f);
    print("double         " + d);
  }

  public static void main(String[] args) {
    MainClass iv = new MainClass();
    iv.printInitialValues();
  }
}
Data type      Initial value
boolean        false
char           []
byte           0
short          0
int            0
long           0
float          0.0
double         0.0








2.1.Data Type Introduction
2.1.1.The Primitive Types
2.1.2.Size for Java's Primitive Types
2.1.3.Default values for primitives and references
2.1.4.Literals
2.1.5.Surprise! Java lets you overflow
2.1.6.Wrapping a Primitive Type in a Wrapper Object: boolean, byte, char, short, int, long, float, double
2.1.7.Print the limits of primitive types (e.g. byte, short, int ...) in Java
2.1.8.Get the minimum and maximum value of a primitive data types
2.1.9.Shows default initial values
2.1.10.Primitive utilities
2.1.11.Return primitive type the passed in wrapper type corresponds to