I've encoutered an error while writing a line like this:
String string;
if (Character.isLetter(string[i])) {...}
Eclipse tells me that The type of the expression must be an array type but it resolved to String
.
It does not raise the error if I use string.charAt(i)
though.
My question is:
What is the difference between string[i]
and string.charAt(i)
in Java
?
Are there any delicate aspects of using one or another?
I've tried to find a solution by myself, but I've encoutered javascript
version of this problem only. (Example: Difference between str[0] and str.charAt(0))