How to initialize static ResourceBundle?

J

J. Bayjan

Since the static objects are null if they are not initialized. But I
don't how I can initialize static ResourceBundle.
code :
public static ResourceBundle resBundle;

if i initialize in this way
public static ResourceBundle resBundle = new ResourceBundle();

compiler error is like: cannot instantiate from class ResourceBundle
it is not a concrete class.

Yes ResourceBundle is abstract class, right? So how can i initialize
this resBundle variable. Because when I use it again later it gives
NullPointerException:(.

Thank you very much for your help!

Best Regards, J. Bayjan!
 
J

Jim Sculley

J. Bayjan said:
Since the static objects are null if they are not initialized. But I
don't how I can initialize static ResourceBundle.
code :
public static ResourceBundle resBundle;

if i initialize in this way
public static ResourceBundle resBundle = new ResourceBundle();

compiler error is like: cannot instantiate from class ResourceBundle
it is not a concrete class.

Yes ResourceBundle is abstract class, right? So how can i initialize
this resBundle variable. Because when I use it again later it gives
NullPointerException:(.

Either instantiate a concrete implementation of the ResourceBundle (such
as PropertyResourceBundle) or call the appropriate static getBundle()
method:

ResourceBundle someBundle = ResourceBundle.getBundle("someBundle");

Jim S.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top