-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString Methods.TXT
More file actions
15 lines (15 loc) · 1.34 KB
/
String Methods.TXT
File metadata and controls
15 lines (15 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
length(): Returns the length of the string.
charAt(int index): Returns the character at the specified index.
indexOf(String str): Returns the index within the string of the first occurrence of the specified substring.
substring(int beginIndex): Returns a new string that is a substring of the original string starting from the specified index.
substring(int beginIndex, int endIndex): Returns a new string that is a substring of the original string, starting from the beginIndex and ending before the endIndex.
toUpperCase(): Returns a new string in uppercase.
toLowerCase(): Returns a new string in lowercase.
trim(): Returns a copy of the string with leading and trailing whitespaces removed.
replace(char oldChar, char newChar): Returns a new string resulting from replacing all occurrences of oldChar with newChar.
startsWith(String prefix) / endsWith(String suffix): Checks if the string starts/ends with the specified prefix/suffix.
contains(CharSequence s): Checks if the string contains the specified sequence of characters.
split(String regex): Splits the string around matches of the given regular expression.
concat(String str): Concatenates the specified string to the end of this string.
equals(Object obj): Compares this string to the specified object.
equalsIgnoreCase(String anotherString): Compares this string to another string, ignoring case considerations.