Q:

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

belongs to collection: Java String Solved Programs

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java String Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a Java Program to Compare Two Strings using ... >>
<< Write a Java Program to Print Simple String entere...