Posts which you will also like.

Sunday, September 5, 2010

Implementing Your Own String Function in JAVA

import javax.swing.JOptionPane;// We have imported Class JOptionPane of swing Package so that
public class CharAt                    //we can use a input and output dialog box of that class
    private String str,st;
    private char calc()
        str=JOptionPane.showInputDialog(null,"Enter a string:");
        st=JOptionPane.showInputDialog(null,"String you entered is:"+str+"\n Enter the index of character to find:");
        int ind=Integer.parseInt(st);
        int len=str.length();
        char ch[]=new char[len];
        return ch[ind-1];
    public void show()
        JOptionPane.showMessageDialog(null,"character is:"+calc());
    public static void main(String []args)
        CharAt a=new CharAt();;

No comments:

Post a Comment

Your comment may wait for moderation.... Protected by Copyscape Online Plagiarism Tool