I want to assign Calendar or Date object which is a global variable in another class. In class Class1 I initialize date object like his:
Calendar date1;
date1 = Calendar.getInstance();
In Class2 I do this:
Calendar date2 = Class1.date1;
Why does it work good if I assign Class1.date1 to date2 inside any method in Class2 but doesn't work if I declare date2 as global variable and assign value Class1.date1? (In this case there will be NullPointerException thrown.)
 
     
    