调用String对象的length()方法就可以获取字符串的长度了
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
System.out.print("Please input a string:");
String input = new Scanner(System.in).nextLine();
System.out.println(input + " length is : " + input.length());
}
}
public static void main(String[] args) {
String input = new Scanner(System.in).nextLine();
Scanner sc = new Scanner(System.in);
String s = sc.netxtLine();
s.length();
}
.,mnbvhjkliuy