I have two questions in Java:
I know that uninitialized object is automatically assigned
nullbut this code doesn't work -A a; //A is some valid user-defined object System.out.println(a != null);This gives error :
error: variable a might not have been initialized.
This indicates thatais not null. So, how do I differentiate betweennulland these kind of vaiables?I know that constructor doesn't return any value not even
voidandreturnreturnsvoid, so how can the following code work perfectly?A() { //...Some code return; //Works perfectly even if it returns void from inside construtor }
int a; if (...) { a = 42; } else { ... }