以下のコードは、文字列を入力するだけで、ユーザー入力を受け付けますが、文字列の文字数は表示されません。親切に助けてください!java内の文字列の文字数を見つける方法
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);
あなたのプログラムが何をすべきか正確に覚えておいてください。 –
そこにはかなり明白な無限ループがあります。 – CollinD