aspose file tools
The moose likes Java in General and the fly likes Null Pointer exception when accessing a static instantiated object with in the instance of Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Null Pointer exception when accessing a static instantiated object with in the instance of

Kalyana Chakravathy
Greenhorn

Joined: Nov 04, 2009
Posts: 8
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

Can anyone tell me why this is so.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Pleaseuse one thread per question. Let's continue here.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Null Pointer exception when accessing a static instantiated object with in the instance of
 
Similar Threads
Query on enhanced FOR loop
Null Pointer exception when accessing a static instantiated object with in the instance of a class.
Pleas help with array
how to store multiple values in one key in hash table
non-static reference in singleton