"END"がコンソールに入力されたときに私のコードを終了しようとしていますが、私のコードは公平に動かず、どこが間違っているのか分からないようです。しかし、これは主に私がそれを理解できない理由と主に関係しています。できるなら助けてください。私はENDを入力すると私のプログラムが終了しないのですか?
import java.util.*;
class Main
{
public static void main(String args[])
{
int j = 0;
while (j++ <= 3) {
// Create Scanner object to take input from command prompt
Scanner s=new Scanner(System.in);
// Take input from the user and store it in st
String st = "";
while (!st.equals("END")) {
{
st=s.nextLine();
// Initialize the variable count to 0
int count=0;
// Convert String st to char array
char[] c=st.toCharArray();
// Loop till end of string
for(int i=0;i<st.length();i++)
// If character at index 'i' is not a space, then increment count
if(c[i]!=' ') count++;
// Print no.of spaces
System.out.printf("[%4d] spaces in ", +(st.length()-count));
// Print no.of spaces
System.out.println('"' + st + '"');
}
j++;
}
}
}
まだデバッグを学んでいない場合は、この資料が役立ちます。[小さなプログラムをデバッグする方法](https://ericlippert.com/2014/03/05/how-to-debug-small-programs /) – EJoshuaS
[デバッガとは何ですか?また、どのようにして問題を診断するのに役立ちますか?](https://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-) it-help-me-diagnose-problems) – EJoshuaS
あなたはそれがないと思いますか? –