i = | s.length() |
length of the string s. |
i = | s.compareTo(t) |
compares to s. returns <0 if s<t, 0 if ==, >0 if s>t |
i = | s.compareToIgnoreCase(t) |
same as above, but upper and lower case are same |
b = | s.equals(t) |
true if the two strings have equal values |
b = | s.equalsIgnoreCase(t) |
same as above ignoring case |
b = | s.startsWith(t) |
true if s starts with t |
b = | s.startsWith(t, i) |
true if t occurs starting at index i |
b = | s.endsWith(t) |
true if s ends with t |
i = | s.indexOf(t) |
index of the first occurrence of String t in s. |
i = | s.indexOf(t, i) |
index of String t at or after position i in s. |
i = | s.indexOf(c) |
index of the first occurrence of char c in s. |
i = | s.indexOf(c, i) |
index of char c at or after position i in s. |
i = | s.lastIndexOf(c) |
index of last occurrence of c in s. |
i = | s.lastIndexOf(c, i) |
index of last occurrence of c on or before i in s. |
i = | s.lastIndexOf(t) |
index of last occurrence of t in s. |
i = | s.lastIndexOf(t, i) |
index of last occurrence of t on or before i in s. |
c = | s.charAt(i) |
char at position i in s. |
s1 = | s.substring(i) |
substring from index i to the end of s. |
s1 = | s.substring(i, j) |
substring from index i to BEFORE index j of s. |
s1 = | s.toLowerCase() |
new String with all chars lowercase |
s1 = | s.toUpperCase() |
new String with all chars uppercase |
s1 = | s.trim() |
new String with whitespace deleted from front and back |
s1 = | s.replace(c1, c2) |
new String with all c2s replaced by c1s. |
b = | s.matches(regexStr) |
true if regexStr matches the entire string in s. Same as Pattern.matches(regexStr, s) |
s1 = | s.replaceAll(regexStr, t) |
replaces each substring that matches regexStr with String t |
s1 = | s.replaceFirst(regexStr, t) |
replaces first substring that matches regexStr with String t |
sa = | s.split(regexStr) |
array of all substrings terminated by regexStr or end |
sa = | s.split(regexStr, count) |
limited to applying regexStr only count times. |
s = | String.valueOf(x) |
Converts x to String, where x is any type value (primitive or object). |
s = | String.format(f, x...) |
[Java 5] Uses format f to convert variable number of parameters, x to a string. |
comp = | String.CASE_INSENSITIVE_ORDER |
A static Comparator object that does case-insensitive comparisons
for sorts and ordered Collections (eg, TreeMap, TreeSet,
SortedMap, and SortedSet). |