< prev index next >

src/java.base/share/classes/java/lang/String.java

Print this page




  61  *     String str = new String(data);
  62  * </pre></blockquote><p>
  63  * Here are some more examples of how strings can be used:
  64  * <blockquote><pre>
  65  *     System.out.println("abc");
  66  *     String cde = "cde";
  67  *     System.out.println("abc" + cde);
  68  *     String c = "abc".substring(2,3);
  69  *     String d = cde.substring(1, 2);
  70  * </pre></blockquote>
  71  * <p>
  72  * The class {@code String} includes methods for examining
  73  * individual characters of the sequence, for comparing strings, for
  74  * searching strings, for extracting substrings, and for creating a
  75  * copy of a string with all characters translated to uppercase or to
  76  * lowercase. Case mapping is based on the Unicode Standard version
  77  * specified by the {@link java.lang.Character Character} class.
  78  * <p>
  79  * The Java language provides special support for the string
  80  * concatenation operator (&nbsp;+&nbsp;), and for conversion of
  81  * other objects to strings. String concatenation is implemented
  82  * through the {@code StringBuilder}(or {@code StringBuffer})
  83  * class and its {@code append} method.

  84  * String conversions are implemented through the method
  85  * {@code toString}, defined by {@code Object} and
  86  * inherited by all classes in Java. For additional information on
  87  * string concatenation and conversion, see Gosling, Joy, and Steele,
  88  * <i>The Java Language Specification</i>.
  89  *
  90  * <p> Unless otherwise noted, passing a {@code null} argument to a constructor
  91  * or method in this class will cause a {@link NullPointerException} to be
  92  * thrown.
  93  *
  94  * <p>A {@code String} represents a string in the UTF-16 format
  95  * in which <em>supplementary characters</em> are represented by <em>surrogate
  96  * pairs</em> (see the section <a href="Character.html#unicode">Unicode
  97  * Character Representations</a> in the {@code Character} class for
  98  * more information).
  99  * Index values refer to {@code char} code units, so a supplementary
 100  * character uses two positions in a {@code String}.
 101  * <p>The {@code String} class provides methods for dealing with
 102  * Unicode code points (i.e., characters), in addition to those for
 103  * dealing with Unicode code units (i.e., {@code char} values).




  61  *     String str = new String(data);
  62  * </pre></blockquote><p>
  63  * Here are some more examples of how strings can be used:
  64  * <blockquote><pre>
  65  *     System.out.println("abc");
  66  *     String cde = "cde";
  67  *     System.out.println("abc" + cde);
  68  *     String c = "abc".substring(2,3);
  69  *     String d = cde.substring(1, 2);
  70  * </pre></blockquote>
  71  * <p>
  72  * The class {@code String} includes methods for examining
  73  * individual characters of the sequence, for comparing strings, for
  74  * searching strings, for extracting substrings, and for creating a
  75  * copy of a string with all characters translated to uppercase or to
  76  * lowercase. Case mapping is based on the Unicode Standard version
  77  * specified by the {@link java.lang.Character Character} class.
  78  * <p>
  79  * The Java language provides special support for the string
  80  * concatenation operator (&nbsp;+&nbsp;), and for conversion of
  81  * other objects to strings. At the discretion of Java compiler,
  82  * String concatenation may be implemented through any JDK API, e.g.
  83  * the {@code StringBuilder} or the {@code java.lang.invoke.StringConcatFactory},
  84  * as long as it satisfies the requirements of the <i>The Java Language Specification</i>.
  85  * String conversions are implemented through the method
  86  * {@code toString}, defined by {@code Object} and
  87  * inherited by all classes in Java. For additional information on
  88  * string concatenation and conversion, see Gosling, Joy, and Steele,
  89  * <i>The Java Language Specification</i>.
  90  *
  91  * <p> Unless otherwise noted, passing a {@code null} argument to a constructor
  92  * or method in this class will cause a {@link NullPointerException} to be
  93  * thrown.
  94  *
  95  * <p>A {@code String} represents a string in the UTF-16 format
  96  * in which <em>supplementary characters</em> are represented by <em>surrogate
  97  * pairs</em> (see the section <a href="Character.html#unicode">Unicode
  98  * Character Representations</a> in the {@code Character} class for
  99  * more information).
 100  * Index values refer to {@code char} code units, so a supplementary
 101  * character uses two positions in a {@code String}.
 102  * <p>The {@code String} class provides methods for dealing with
 103  * Unicode code points (i.e., characters), in addition to those for
 104  * dealing with Unicode code units (i.e., {@code char} values).


< prev index next >