Null Pointer exception when accessing a static instantiated object with in the instance of
Kalyana Chakravathy
Greenhorn
Joined: Nov 04, 2009
Posts: 8
posted
0
I am facing one weird problem when accessing a static object instance,
Test.java:
Run.java
On running Run it gives me a NPE,
[jkalyana@toddler ~]$ javac Test.java
[jkalyana@toddler ~]$ vim Run.java
[jkalyana@toddler ~]$ javac Run.java
[jkalyana@toddler ~]$ java Run
Exception in thread "main" java.lang.ExceptionInInitializerError at Run.main(Run.java:3)
Caused by: java.lang.NullPointerException at Test.enter(Test.java:10)
at Test.<init>(Test.java:7)
at Test.<clinit>(Test.java:4)
... 1 more
I had a doubt and changed the Test.java to this,
On moving the declaration of Test below map, it runs,
[jkalyana@toddler ~]$ java Run
Key = dummy1, Value = dummy2