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:

  1. s.charAt(index)
  2. char[] charArr = s.toCharArray(); and access charArr[idx]