+ 2
Why this program is generating the exception?
Why this program is generating the exception?? public class R { String s = "RA!"; R A; R(){ System.out.print(A.s); } } class test { public static void main(String [] g) { R B = new R(); } }
2 Réponses
+ 1
Because the constructor for A is currently running and A hasn't been assigned as yet so it is null.
+ 1
Forget my previous post. If that were true, I should have gotten two outputs not one. It is because A is uninitialized as you need to assign this to it.