Saturday, October 17, 2015

Program to find length of string using built-in string fuctiion.

import java.io.*;
class Len
{
    public static void main(String args[])
    {
        System.out.println("Enter a string:");
        DataInputStream s=new DataInputStream(System.in);
        try
        {
            String str=s.readLine();
            int le=str.length();
            System.out.println("String length="+le);
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}

Output:

No comments:

Post a Comment