int len = str.length();
char ch = str.charAt(0);
String sub = str.substring(1, 4);
Finds the first occurrence of a specified character or substring in the string.
int index = str.indexOf("abc");
Finds the last occurrence of a specified character or substring in the string.
int lastIndex = str.lastIndexOf("abc");
Split the string according to the seperator and put it in an array.
String[] parts = str.split(",");
char[] chars = str.toCharArray();
Replaces all occurrences of the target sequence with the replacement sequence.
String newStr = str.replace("a", "b");
boolean isEqual = str1.equals(str2);
// without looking at upper or lower case
boolean isEqualIgnoreCase = str1.equalsIgnoreCase(str2);
String trimmed = str.trim();
Checks if the string starts or ends with the specified prefix/suffix.
boolean starts = str.startsWith("abc");
boolean ends = str.endsWith("xyz");
Converts a string to an int.
int num = Integer.parseInt("123");
Converts string to an Integer object.
Integer num = Integer.valueOf("123");
Converts int to a string
String str = Integer.toString(123);
Integer.compare(a,b)
int result = Integer.compare(5, 10); // returns negative because 5 < 10
int max = Integer.max(5, 10);
int min = Integer.min(5, 10);
int sum = Integer.sum(5, 10);