Non-initialized string instance variable : Member Variable « Java Source And Data Type « SCJP






public class MainClass {
  private String title;          // instance reference variable
  public String getTitle() {
    return title;
  }
  public static void main(String [] args) {
    MainClass b = new MainClass();
    System.out.println("The title is " + b.getTitle());
  }
}








1.20.Member Variable
1.20.1.Field Variables are variables that are declared as members of classes.
1.20.2.Field variables are declared using the following syntax: modifiers Type declarator;
1.20.3.Java supports two different kinds of variables: field variables and local variables.
1.20.4.Field variables of object types and the elements of arrays of object types are automatically initialized to the null value.
1.20.5.Initialization Values for Member Variables(the same as array element initialization values)
1.20.6.Default initializations of static and instance variables.
1.20.7.A member value may be initialized in its own declaration line:
1.20.8.nonstatic instance variables are initialized before the class constructor is executed
1.20.9.Non-initialized string instance variable
1.20.10.Array Instance Variables