The JDK 1.1 release added many features to make it easy for programmers to develop internationalized programs. Some changes were required to theString
class to make it a better international citizen. In fact, all of the changes made to theString
class are related to internationalization issues.Be careful: Some uses of the
String
andStringBuffer
classes may compromise the "international quality" of your program. See Writing Global Programs for a discussion about managing text in a global fashion.The first column in the following table lists the constructors and methods in theString
class that are deprecated in the JDK 1.1. The second column lists alternatives for those constructors and methods:
These constructors and methods were deprecated because they did not properly convert bytes into characters. The new constructors and methods use a named character-encoding or the default character-encoding to do the conversion.
Deprecated Methods Alternatives String(byte[], int)
String(byte[]) or String(byte[], String)
String(byte[], int, int, int)
String(byte[], int, int) or String(byte[], int, int, String)
getBytes(int, int, byte[], int)
byte[] getBytes(String)
orbyte[] getBytes()
New Methods
These constructors and methods were added to theString
class for the JDK 1.1.The four new constructors and the two newString(byte[]) String(byte[], int, int) String(byte[], String) String(byte[], int, int, String) byte[] getBytes(String) byte[] getBytes() String toLowerCase(Locale) String toUpperCase(Locale)getBytes
methods are described in the previous section. The other two methods,toLowerCase
andtoUpperCase
convert theString
to lower or upper case according to the rules in the specifiedLocale
. For information aboutLocale
s and writing internationalized programs, see the new lesson Writing Global Programs.