文字(「a」を調べるため)が見つかるたびにそれを出力し、次の文字に移動してチェックするプログラムを作成しようとしています。word.length の終わりまでそれを続けます。それは私がこれまでやってきたことですが、うまくいきません。
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a word: ");
String word = in.next();
String a = "a";
int i;
char found = 0;
char F;
for (i = 0; i < word.length(); i++)
{
F = word.charAt(i);
if (F == found)
{
System.out.println(i);
}
}
}