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

By | 09.02.2017

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


Java Program to find the length of the string in Java Programming, you have to ask to the user to enter the string and then find the length of that string using the method length() and display the length value of the string on the output screen as shown in the following program.

 

SOURCE CODE ::

import java.util.Scanner;

public class find_length
{
   public static void main(String args[])
   {
      String str;
      int len;
      Scanner scan = new Scanner(System.in);
          
      System.out.print("Enter Your Name : ");
      str = scan.nextLine();
      len = str.length();
          
      System.out.print("Length of Entered String is " + len);
   }
}

 

OUTPUT ::

 

Enter Your Name : CodezClub

Length of Entered String is 9

 

3 1 vote
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments