Saturday, 15 June 2013

Use of java string function length()

import java.io.*;

public class length_function
{
    public static void main(String []args)
    {
        String str;
        try
        {
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter first String ");
            str=cin.readLine();
            int i=str.length();
            System.out.println("length of given string is : "+i);
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}

No comments: