Friday, 14 June 2013

java program for string funtin charAt()

import java.io.*;
class simple_charAt_pos
{
    public static void main(String args[])
    {
        String str;
        char s;
        try
        {
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter any String ");
            str=cin.readLine();
            System.out.println("Your entered string is = "+str);
            s=str.charAt(2);
            System.out.println("Character of that possition is = "+s);
        }
        catch(Exception e)
        {
            System.out.println("wrong data");
        }
    }
}

No comments: