aspose file tools*
The moose likes Beginning Java and the fly likes Accessing a final static variable using Field.get(...) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Accessing a final static variable using Field.get(...)" Watch "Accessing a final static variable using Field.get(...)" New topic
Author

Accessing a final static variable using Field.get(...)

Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
Hi,
I am trying to get access to four String constants elsewhere in my API. Which four constants is determined based on the input data. My code compiles, but throws a NullPointerException. This is what it looks like:

The first try block executes nicely. I get a NullPointer in the second. I have tried sending both "null" and "new String()" as parameters to Field.get(), neither with success.
The constants I'm trying to capture look like this:

Can anyone see what I'm doing wrong?
Many thanks,
g.
[ July 03, 2002: Message edited by: Garann Rose Means ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing a final static variable using Field.get(...)
 
Similar Threads
how to read string value using java reflection
problem with using rs.getString() in servlet.
How to access private static variables outside the class?
How to access Constant from a constant class in JSTL(JSP page)
converting a string color to an object color