java 用方法 判断字符串的长度怎么写

2025-03-05 05:27:12
推荐回答(3个)
回答1:

public static void main(String agrs[]) {
Scanner input= new Scanner(System.in);
String str=input.next();
System.out.println(str.length());//length()用于输出字符串长度的方法
}

回答2:

str.length()不就返回长度了吗

回答3:

模10循环