Java Program to Find Length of String using length() method
Example:
import java.util.Scanner;
public class StringLength
{
public static void main(String args[])
{
String str;
int len;
Scanner scan = new Scanner(System.in);
System.out.print("Enter any String: ");
str = scan.nextLine();
len = str.length();
System.out.print("Length of the String is: " + len);
}
}
Output:
Enter any String: Webisworld Length of the String is: 10
Share this page on:
Subscribe Email Updates
to get latest update