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:
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