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:~$
Comments and Reactions
What Next?
Java program to find the length of a given string
How to find the length of a string without using the length method in java
Java program to reverse a given string using the reverse method
Advertisement