Core APIs Flashcards
STRING: int length()
Returns the length of the string
STRING: char charAt(int index)
Returns the character at the specified index in the string.
STRING: int indexOf(int ch, int fromIndex)
Returns the index of the first occurrence of the specified character, starting the search at fromIndex.
STRING: int indexOf(String str)
Returns the index of the first occurrence of the specified substring.
STRING: String substring(int beginIndex)
Returns a new string that is a substring of this string, starting from beginIndex to the end.
STRING: int indexOf(String str, int fromIndex)
Returns the index of the first occurrence of the specified substring, starting the search at fromIndex.
STRING: String substring(int beginIndex, int endIndex)
Returns a new string that is a substring of this string, starting from beginIndex and ending at endIndex - 1.
STRING: String toLowerCase()
Converts all characters in the string to lowercase.
STRING: String toUpperCase()
Converts all characters in the string to uppercase.
STRING: boolean equals(Object obj)
Compares this string to the specified object for equality.
STRING: boolean startsWith(String prefix)
Tests if this string starts with the specified prefix.
STRING: boolean equalsIgnoreCase(String str)
Compares this string to another string, ignoring case considerations.
STRING: boolean endsWith(String suffix)
Tests if this string ends with the specified suffix.
STRING: boolean contains(CharSequence charSeq)
Returns true if and only if this string contains the specified sequence of characters.
STRING: String replace(char oldChar, char newChar)
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
STRING: String replace(CharSequence target, CharSequence replacement)
Replaces each substring of this string that matches the literal target sequence with the specified replacement sequence.
How to return the length of the string?
int length()
How to get the character at a specific index in the string?
char charAt(int index)
How to find the index of a character, starting the search from a specific index?
int indexOf(int ch, int fromIndex)
How to find the index of the first occurrence of a substring?
int indexOf(String str)
How to find the index of a substring, starting the search from a specific index?
int indexOf(String str, int fromIndex)
How to get a substring from a specific index to the end of the string?
String substring(int beginIndex)
How to get a substring between two specified indices?
String substring(int beginIndex, int endIndex)
How to convert all characters in the string to lowercase?
String toLowerCase()