Java implementation of the charAt method
GD.java
class GD { 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
godarda@gd:~$ javac GD.java
godarda@gd:~$ java GD H D godarda@gd:~$
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