An immutable sequence of characters/code units (chars). A String is represented by array of UTF-16 values, such that Unicode supplementary characters (code points) are stored/encoded as surrogate pairs via Unicode code units (char). Backing Arrays
| 59 | * @since 1.0 |
| 60 | */ |
| 61 | public final class String implements Serializable, Comparable<String>, CharSequence { |
| 62 | |
| 63 | private static final long serialVersionUID = -6849794470754667710L; |
| 64 | |
| 65 | private static final char REPLACEMENT_CHAR = (char) 0xfffd; |
| 66 | |
| 67 | /** |
| 68 | * CaseInsensitiveComparator compares Strings ignoring the case of the |
| 69 | * characters. |
| 70 | */ |
| 71 | private static final class CaseInsensitiveComparator implements |
| 72 | Comparator<String>, Serializable { |
| 73 | private static final long serialVersionUID = 8575799808933029326L; |
| 74 | |
| 75 | /** |
| 76 | * Compare the two objects to determine the relative ordering. |
| 77 | * |
| 78 | * @param o1 |
| 79 | * an Object to compare |
| 80 | * @param o2 |
| 81 | * an Object to compare |
| 82 | * @return an int < 0 if object1 is less than object2, 0 if they are |
| 83 | * equal, and > 0 if object1 is greater |
| 84 | * |
| 85 | * @exception ClassCastException |
| 86 | * if objects are not the correct type |
| 87 | */ |
| 88 | public int compare(String o1, String o2) { |
| 89 | return o1.compareToIgnoreCase(o2); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * A comparator ignoring the case of the characters. |
| 95 | */ |
| 96 | public static final Comparator<String> CASE_INSENSITIVE_ORDER = new CaseInsensitiveComparator(); |
| 97 | |
| 98 | private static final char[] ASCII; |
| 99 | static { |
| 100 | ASCII = new char[128]; |
| 101 | for (int i = 0; i < ASCII.length; ++i) { |
| 102 | ASCII[i] = (char) i; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | private final char[] value; |
| 107 | |
| 108 | private final int offset; |
| 109 | |
| 110 | private final int count; |
| 111 | |
| 112 | private int hashCode; |
| 113 | |
| 114 | /** |
| 115 | * Creates an empty string. |
| 116 | */ |
| 117 | public String() { |
| 118 | value = EmptyArray.CHAR; |
nothing calls this directly
no outgoing calls
no test coverage detected