Notice


AWT and SWING will be covered soon !

Sunday, September 20, 2009

Get a Letter from a String

 

image

 

import java.util.Scanner;

public class charstr

{
    public static void main (String args[])
    {
        Scanner strscan=new Scanner(System.in);


        int index=0;
        String str;
        char output;


        System.out.print("Enter the String : ");
        str=strscan.next();
        System.out.print("Enter the Index : ");
        index=strscan.nextInt();


        output=str.charAt(index-1);
        System.out.print("The Letter in index ["+index+"]is : "+output);


    }

No comments:

Post a Comment