char charAtPosition7 = myString.charAt(6);
substring
method. There are two variants of the substring
method:
The first one extracts string from the beginIndex to endIndex
Initial string This is string tutorial char at position 7 s Substring from 9th char to 14th char string End of string tutorial
split
method exists. There are two variants of split method:
The first returns an array of string that matches the regex:
The second has a limit for the capacity of the array:
For example we can extract all the words from the string that are divided by space:
The output:
This is string tutorial
trim
. This method removes extra space characters from the begin and end of the string:
int indexOf(int ch)
int lastIndexOf(int ch)
int indexOf(int ch, int fromIndex) int lastIndexOf(int ch, int fromIndex)
boolean contains(CharSequence s)