Java Examples
Java ExamplesPrograms with output

Java Program to Find Length of String using length() method

import java.util.Scanner;
public class StringLength
   public static void main(String args[])
      String str;
      int len;
      Scanner scan = new Scanner(;
      System.out.print("Enter any String: ");
      str = scan.nextLine();
      len = str.length();
      System.out.print("Length of the String is: " + len);
Enter any String: Webisworld
Length of the String is: 10

Share this page on:

Was this page helpful ?

Let us know how we did!

Subscribe Email Updates

to get latest update