In this program, You will learn how to find the length of string using length method in java.
String str = "Hello";
5 = str.length();
import java.util.Scanner;
class Main {
public static void main(String args[]) {
int size;
String str;
Scanner sc = new Scanner(System.in);
System.out.print("Enter a string value:");
str = sc.nextLine();
size = str.length();
System.out.println("String length is:" + size);
}
}
Enter a string value:Xiith.com
String length is:9