Which type is str[0] in string "abc" [duplicate]
The square brackets are used to access the elements in an Array type.
String is an object, and so you can't access it's characters via [].
To access individual characters, you could either:
- s.charAt(index)
- char[] charArr = s.toCharArray(); and access charArr[idx]