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.



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);




Enter Your Name : CodezClub

Length of Entered String is 9


4 2 votes
Article Rating
Category: Java Programming String Programs Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Notify of

Inline Feedbacks
View all comments