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);
}
}
OUTPUT ::
Enter Your Name : CodezClub
Length of Entered String is 9
SOURCE CODE ::
OUTPUT ::
need an explanation for this answer? contact us directly to get an explanation for this answer