java.lang.Object
|
+--java.lang.String
The
String class represents character strings. All
string literals in Java programs, such as "abc", are
implemented as instances of this class.
Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:
String str = "abc";
is equivalent to:
char data[] = {'a', 'b', 'c'};
String str = new String(data);
Here are some more examples of how strings can be used:
System.out.println("abc");
String cde = "cde";
System.out.println("abc" + cde);
String c = "abc".substring(2,3);
String d = cde.substring(1, 2);
The class String includes methods for examining
individual characters of the sequence, for comparing strings, for
searching strings, for extracting substrings, and for creating a
copy of a string with all characters translated to uppercase or to
lowercase.
The Java language provides special support for the string
concatentation operator ( + ), and for conversion of
other objects to strings. String concatenation is implemented
through the StringBuffer class and its
append method.
String conversions are implemented through the method
toString, defined by Object and
inherited by all classes in Java. For additional information on
string concatenation and conversion, see Gosling, Joy, and Steele,
The Java Language Specification.
Object.toString(),
StringBuffer,
StringBuffer.append(boolean),
StringBuffer.append(char),
StringBuffer.append(char[]),
StringBuffer.append(char[], int, int),
StringBuffer.append(double),
StringBuffer.append(float),
StringBuffer.append(int),
StringBuffer.append(long),
StringBuffer.append(java.lang.Object),
StringBuffer.append(java.lang.String),
Character encodings, Serialized Form
| Field Summary | |
static Comparator |
CASE_INSENSITIVE_ORDER
copy-> CASE_INSENSITIVE_ORDER
|
| Constructor Summary | |
String
copy-> new String()copy-> <String var> = new String();
|
|
String
copy-> new String( )copy-> <String var> = new String(<byte[] bytes>);
|
|
String
copy-> new String(, )copy-> <String var> = new String(<byte[] ascii>, <int hibyte>);
|
|
String
copy-> new String(, , )copy-> <String var> = new String(<byte[] bytes>, <int offset>, <int length>);
|
|
String
copy-> new String(, , , )copy-> <String var> = new String(<byte[] ascii>, <int hibyte>, <int offset>, <int count>);
|
|
String
copy-> new String(, , , )copy-> <String var> = new String(<byte[] bytes>, <int offset>, <int length>, <String enc>);
|
|
String
copy-> new String(, )copy-> <String var> = new String(<byte[] bytes>, <String enc>);
|
|
String
copy-> new String( )copy-> <String var> = new String(<char[] value>);
|
|
String
copy-> new String(, , )copy-> <String var> = new String(<char[] value>, <int offset>, <int count>);
|
|
String
copy-> new String( )copy-> <String var> = new String(<String value>);
|
|
String
copy-> new String( )copy-> <String var> = new String(<StringBuffer buffer>);
|
|
| Method Summary | |
char |
charAt(int index)
copy-> .charAt( )copy-> <char var>=<String>.charAt(<int index>);
|
int |
compareTo(Object o)
copy-> .compareTo( )copy-> <int var>=<String>.compareTo(<Object o>);
|
int |
compareTo(String anotherString)
copy-> .compareTo( )copy-> <int var>=<String>.compareTo(<String anotherString>);
|
int |
compareToIgnoreCase(String str)
copy-> .compareToIgnoreCase( )copy-> <int var>=<String>.compareToIgnoreCase(<String str>);
|
String |
concat(String str)
copy-> .concat( )copy-> <String var>=<String>.concat(<String str>);
|
static String |
copyValueOf(char[] data)
copy-> String.copyValueOf( )copy-> <String var>=String.copyValueOf(<char[] data>);
|
static String |
copyValueOf(char[] data,
int offset,
int count)
copy-> String.copyValueOf(, , )copy-> <String var>=String.copyValueOf(<char[] data>, <int offset>, <int count>);
|
boolean |
endsWith(String suffix)
copy-> .endsWith( )copy-> <boolean var>=<String>.endsWith(<String suffix>);
|
boolean |
equals(Object anObject)
copy-> .equals( )copy-> <boolean var>=<String>.equals(<Object anObject>);
|
boolean |
equalsIgnoreCase(String anotherString)
copy-> .equalsIgnoreCase( )copy-> <boolean var>=<String>.equalsIgnoreCase(<String anotherString>);
|
byte[] |
getBytes()
copy-> .getBytes()copy-> <byte var>=<String>.getBytes();
|
void |
getBytes(int srcBegin,
int srcEnd,
byte[] dst,
int dstBegin)
copy-> .getBytes(, , , )copy-> <String>.getBytes(<int srcBegin>, <int srcEnd>, <byte[] dst>, <int dstBegin>);
|
byte[] |
getBytes(String enc)
copy-> .getBytes( )copy-> <byte var>=<String>.getBytes(<String enc>);
|
void |
getChars(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
copy-> .getChars(, , , )copy-> <String>.getChars(<int srcBegin>, <int srcEnd>, <char[] dst>, <int dstBegin>);
|
int |
hashCode()
copy-> .hashCode()copy-> <int var>=<String>.hashCode();
|
int |
indexOf(int ch)
copy-> .indexOf( )copy-> <int var>=<String>.indexOf(<int ch>);
|
int |
indexOf(int ch,
int fromIndex)
copy-> .indexOf(, )copy-> <int var>=<String>.indexOf(<int ch>, <int fromIndex>);
|
int |
indexOf(String str)
copy-> .indexOf( )copy-> <int var>=<String>.indexOf(<String str>);
|
int |
indexOf(String str,
int fromIndex)
copy-> .indexOf(, )copy-> <int var>=<String>.indexOf(<String str>, <int fromIndex>);
|
String |
intern()
copy-> .intern()copy-> <String var>=<String>.intern();
|
int |
lastIndexOf(int ch)
copy-> .lastIndexOf( )copy-> <int var>=<String>.lastIndexOf(<int ch>);
|
int |
lastIndexOf(int ch,
int fromIndex)
copy-> .lastIndexOf(, )copy-> <int var>=<String>.lastIndexOf(<int ch>, <int fromIndex>);
|
int |
lastIndexOf(String str)
copy-> .lastIndexOf( )copy-> <int var>=<String>.lastIndexOf(<String str>);
|
int |
lastIndexOf(String str,
int fromIndex)
copy-> .lastIndexOf(, )copy-> <int var>=<String>.lastIndexOf(<String str>, <int fromIndex>);
|
int |
length()
copy-> .length()copy-> <int var>=<String>.length();
|
boolean |
regionMatches(boolean ignoreCase,
int toffset,
String other,
int ooffset,
int len)
copy-> .regionMatches(, , , , )copy-> <boolean var>=<String>.regionMatches(<boolean ignoreCase>, <int toffset>, <String other>, <int ooffset>, <int len>);
|
boolean |
regionMatches(int toffset,
String other,
|