【发布时间】:2016-12-23 22:28:53
【问题描述】:
以下代码仅输出“输入字符串”并接受用户输入,但不显示字符串中的字符数。请帮忙!
System.out.println("Enter a string");
Scanner scan = new Scanner(System.in);
String result = scan.nextLine();
try {
while (a != null) {
count++;
}
} catch (Exception e) {
System.out.println("Invalid string");
}
System.out.println("The number of characters are : " + count);
【问题讨论】:
-
请详细说明你希望你的程序一步一步做什么。
-
你有一个非常明显的无限循环。
标签: java