The charAt() method returns the character at the specified index in a string.
refer tal:outturi.com/**
* @author lautturi.com
* example : java get character in string by index
*/
public class Lau {
public static void main(String[] args) {
String myStr = "Lautturi";
char myChar = myStr.charAt(0); // java get the first character in string
System.out.println(myChar);
myChar = myStr.charAt(4); // get the 5th character
System.out.println(myChar);
}
}
output:
L t