I have some doubt regarding how class variable gets initialized, both static and non static. I mean, suppose I have a class like below.
public class MyClass{
public static HashMap<String,Buddy> buddiesMap= new HashMap<String,Buddy>();
public static ArrayList<String> buddiesList=new ArrayList<String>();
public static HashMap<String,ImageIcon> avatarMap=new HashMap<String, ImageIcon>();
public static ServerConnection con=new ServerConnection();
public MyClass(){
}
}
Now Suppose I access "con" object from somewhere outside this class and I never created any instance or initialized MyClass before. Like I write:
ServerConnection c=MyClass.con;
Now will the other static members also get initialized automatically when for the first time I accessed a static member among them? or they get initialized only when we get them into reference?