Java implementation of the charAt method
KW.java
class KW
{
    public static void main(String args[])
    {
        String s="HELLO WORLD";

        char c1=s.charAt(0);    //At 0th Position
        System.out.println(c1);

        char c2=s.charAt(5);
        System.out.println(c2);

        char c3=s.charAt(10);
        System.out.println(c3);
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW H D kodingwindow@kw:~$
Advertisement