Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to initialize static ResourceBundle?

Reply
Thread Tools

How to initialize static ResourceBundle?

 
 
J. Bayjan
Guest
Posts: n/a
 
      01-26-2004
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!
 
Reply With Quote
 
 
 
 
Jim Sculley
Guest
Posts: n/a
 
      01-27-2004
J. Bayjan wrote:
> 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.

--
Remove my extraneous mandibular appendages to reply via email.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
best way to initialize static member objects cppaddict C++ 16 07-11-2012 11:28 AM
if instance variable get initialize after assigning some values or after constructor then when does static variable get initialize Tony Morris Java 3 02-04-2006 08:39 AM
accessing static constant does not initialize class Tarlika Elisabeth Schmitz Java 2 12-12-2004 12:15 AM
How to Initialize const static object data members in a header file? Seb C++ 2 04-13-2004 02:01 PM
Initialize an static array in a class RCAJ C++ 6 12-28-2003 04:31 PM



Advertisments