You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
char charAt(int index) – Returns the character at the specified index. The specified index value should be between '0' to 'length() -1' both inclusive. It throws IndexOutOfBoundsException if index is invalid/ out of range.
boolean equals(Object obj) – Compares the string with the specified string and returns true if both match else false.
int compareTo(String string) – Compares the two strings lexicographically based on the Unicode value of each character in the strings. You can consider it a dictionary-based comparison. The return value is 0 if the argument string is equal to this string; a value less than 0 if this string is lexicographically less than the string argument, and a value greater than 0 if this string is lexicographically greater than the string argument.
boolean startsWith(String prefix) – Tests whether the string is having specified prefix, if yes then it returns true else false. The offset index value is 0 in this overloaded method.
int indexOf(int ch) – Returns the index of first occurrence of the specified character argument in the string.
int indexOf(int ch, int fromIndex) – Overloaded version of indexOf(char ch) method however it starts searching in the string from the specified fromIndex.
int indexOf(String str) – Returns the index of first occurrence of specified substring 'str'.
int indexOf(String str, int fromIndex) – Overloaded version of indexOf(String str) method however it starts searching in the string from the specified fromIndex.
String[] split(String regex, int limit) – Splits the string and returns the array of sub-strings that matches the given regular expression. 'limit' is a maximum number of elements in array.
String toLowerCase() – Overloaded version of previous method with default locale.
String intern() – Searches the specified string in the memory pool and returns its reference if it is found. Otherwise, this method allocates creates string literal in string pool and return the reference.