basically I need to get a constant for a class however I have no instance of the object but only its class. In PHP I would do constant(XYZ); Is there a similar way
constant(XYZ);
To get private constant like:
private static final String BAR = "test";
you need to set it accessible first:
Field barField = Foo.class.getDeclaredField("BAR"); barField.setAccessible(true); String bar = (String) barField.get(null);