+ 6

How can you refer to a char of a string.

well I know the endsWith and starts with method . but is there any other method .

10th Apr 2017, 4:53 AM
arpit dixit
arpit dixit - avatar
5 odpowiedzi
+ 3
.charAt gives you the chart at a certain position .indexOf returns the first position a particular character is found. You can look all this up. Google for java SE API.
10th Apr 2017, 4:58 AM
1of3
1of3 - avatar
+ 15
Use stringVar.charAt(index) to get any one character as a char. The index works like that for an array, so start at 0. Or, use stringVar.substring(index, index + 1) to get a single character as a string.
10th Apr 2017, 4:59 AM
Tamra
Tamra - avatar
+ 7
thanks
10th Apr 2017, 5:02 AM
arpit dixit
arpit dixit - avatar
+ 7
.charAt(<index>)
10th Apr 2017, 5:05 AM
Saumya
Saumya - avatar
+ 3
string.charAt(index) or string.subString(startIndex, endIndex)
10th Apr 2017, 5:07 AM
Deddy Tandean