MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / String

Class String

vm/JavaAPI/src/java/lang/String.java:39–950  ·  view source on GitHub ↗

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 th

Source from the content-addressed store, hash-verified

37 * Since: JDK1.0, CLDC 1.0 See Also:Object.toString(), StringBuffer, StringBuffer.append(boolean), StringBuffer.append(char), StringBuffer.append(char[]), StringBuffer.append(char[], int, int), StringBuffer.append(int), StringBuffer.append(long), StringBuffer.append(java.lang.Object), StringBuffer.append(java.lang.String)
38 */
39public final class String implements java.lang.CharSequence, Comparable<String> {
40
41 public static final Comparator<String> CASE_INSENSITIVE_ORDER = new Comparator<String>() {
42 public int compare(String o1, String o2){
43 return o1.compareToIgnoreCase(o2);
44 }
45 };
46
47 private static ArrayList<String> str = new ArrayList<String>();
48
49 private final char[] value;
50
51 private final int offset;
52
53 private final int count;
54
55 private int hashCode;
56
57 // cached native string
58 private long nsString;
59 private static final char[] ZERO_CHAR = new char[0];
60
61 /**
62 * Initializes a newly created String object so that it represents an empty character sequence.
63 */
64 public String(){
65 value = ZERO_CHAR;
66 offset = 0;
67 count = 0;
68 }
69
70 /**
71 * Construct a new String by converting the specified array of bytes using the platform's default character encoding. The length of the new String is a function of the encoding, and hence may not be equal to the length of the byte array.
72 * bytes - The bytes to be converted into characters
73 * JDK1.1
74 */
75 public String(byte[] bytes){
76 this(bytes, 0, bytes.length);
77 }
78
79 /**
80 * Construct a new String by converting the specified subarray of bytes using the platform's default character encoding. The length of the new String is a function of the encoding, and hence may not be equal to the length of the subarray.
81 * bytes - The bytes to be converted into charactersoff - Index of the first byte to convertlen - Number of bytes to convert
82 * JDK1.1
83 */
84 public String(byte[] bytes, int off, int len){
85 this(bytesToChars(bytes, off, len, "UTF-8"));
86 }
87
88 /**
89 * Construct a new String by converting the specified subarray of bytes using the specified character encoding. The length of the new String is a function of the encoding, and hence may not be equal to the length of the subarray.
90 * bytes - The bytes to be converted into charactersoff - Index of the first byte to convertlen - Number of bytes to convertenc - The name of a character encoding
91 * - If the named encoding is not supported
92 * JDK1.1
93 */
94 public String(byte[] bytes, int off, int len, java.lang.String enc) throws java.io.UnsupportedEncodingException{
95 this(bytesToChars(bytes, off, len, enc));
96 }

Callers 15

writePngFunction · 0.50
runBundleFunction · 0.50
writePngFromDataUrlFunction · 0.50
yFunction · 0.50
AtFunction · 0.50
nFunction · 0.50
numberReplaceMethod · 0.50
dFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected