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.
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.
Returns the character at the specified index.
Compares two strings lexicographically.
Concatenates the specified string to the end of this string.
Tests if this string ends with the specified suffix.
Compares this string to the specified object.
Compares this String to another object.
Returns the index within this string of the first occurrence of the specified substring.
Returns the index within this string of the rightmost occurrence of the specified substring.
Returns the length of this string.
regionMatches(int, String, int, int)
Tests if two string regions are equal.
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
Tests if this string starts with the specified prefix.
substring(int startchar, int endchar)
Returns a new string that is a substring of this string starting at character startchar and ending at character endchar-1. The returned string has the length endchar – startchar.
Converts this String to lowercase.
Converts this string to uppercase.
Removes white space from both ends of this string.
Returns the string representation of the double argument.
Returns the string representation of the float argument.
Returns the string representation of the int argument
A StringBuffer object is similar to a String, but it can be changed. The following methods are available for StringBuffer.
Appends the string to this string buffer.
the character at the specified position in this
StringBuffer (shortening the
by one character).
the characters in a substring of this
the string representation of the
char argument into this string buffer.
Inserts the string into this string buffer.
The reverse of the sequence replaces the character sequence contained in this string buffer.