Java Reference
In-Depth Information
13.2. The String Class
Strings are immutable (read-only) character sequences: Their contents
can never be changed after the string is constructed. The String class
provides numerous methods for working with stringssearching, compar-
ing, interacting with other character sequencesan overview of which is
given in the following sections.
13.2.1. Basic String Operations
You can create strings implicitly either by using a string literal (such as
"Gröçe" ) or by using + or += on two String objects to create a new one.
You can also construct String objects explicitly using new . The String class
supports the following simple constructors (other constructors are shown
in later sections):
public String()
Constructs a new String with the value "" an empty string.
public String(String value)
Constructs a new String that is a copy of the specified String
object value this is a copy constructor. Because String objects
are immutable, this is rarely used.
public String(StringBuilder value)
Constructs a new String with the same contents as the given
StringBuilder .
public String(StringBuffer value)
 
Search WWH ::




Custom Search