Import java. util. locale;
Import java. util. missingresourceexception;
Import java. util. resourcebundle;
Public class testi18n ...{
Private String title = gettitle ("title ");
Public static void main (string [] ARGs )...{
Testi18n testi18n = new testi18n ();
System. Out. Print ("title is" + testi18n. Title );
}
Private string gettitle (string key )...{
Resourcebundle = resourcebundle. getbundle (this. getclass (). getname (), locale. simplified_chinese );
String value = NULL;
Try ...{
Value = resourcebundle. getstring (key );
} Catch (missingresourceexception me )...{
Me. printstacktrace ();
}
Return value;
}
}
When initializing the testi18n constructor, we must first execute the initialization of the variable title. At this time, resourcebundle will be called to internationalize, And the bug will pop up. I also heard that Java 6 has added some new functions to the international market. We can see that the bug caused by the upgrade of Java 6 is fixed with the Java version of the local machine.
C:/Documents and Settings/New> JAVA-version
Java version "1.6.0-RC"
Java (TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b66)
Java hotspot (TM) Client VM (build 1.6.0-rc-b66, mixed mode, sharing)
I checked the newest version is the jdk-6u2-ea of megal 12,200 7, I don't know if this bug has been fixed