Java Basic Tutorial
Java Advance Tutorial
Method |
Description |
Example |
---|---|---|
charAt(int index) |
Returns the character at the specified index. |
|
length() |
Returns the length of the string. |
|
substring(int start, int end) |
Extracts a substring. |
|
indexOf(String str) |
Returns the first index of a substring. |
|
lastIndexOf(String str) |
Returns the last index of a substring. |
|
replace(char old, char new) |
Replaces characters in the string. |
|
toUpperCase() |
Converts the string to uppercase. |
|
toLowerCase() |
Converts the string to lowercase. |
|
trim() |
Removes leading and trailing spaces. |
|
split(String regex) |
Splits the string into an array based on a regex. |
|
startsWith(String prefix) |
Checks if the string starts with the prefix. |
|
endsWith(String suffix) |
Checks if the string ends with the suffix. |