charAt() in String
charAt() has return type char and It gets index number as an argument.
Suppose we have a string as follows:
String str = "Ankit Shravanekar";
then it's structure will be in the memory as following picture:
And suppose, we want to get Character 'k' which is situated at the index number '2'. Then, we will call charAt(2) to get character 'k' and we will store this 'k' in a variable of char type as follows:
char c = str.charAt(2);
Following program shows - By calling charAt(), how we can get desired character from a string.