簡単なスペルチェッカープログラムを書いていますが、ループに問題があり、理解できないようです。これが私のコードです
public class spellchecker {
public static void main(String[] args) {
// setting up dictionary
String[] dictionary = {"win","winner","know","born","were","plan","must","you","correct","college", "to"} ;
//defining our sentence
String sentence = "You were born to win but to be a winners you must plan to win prepare to win and expect to win";
//splitting sentence into an array of words
String[] split = sentence.split("\\s");
for(int i = 0; i<split.length; i++)
{
if(split[i].equals(dictionary[0]) || split[i].equals(dictionary[1]) || split[i].equals(dictionary[2]) || split[i].equals(dictionary[3]) || split[i].equals(dictionary[4]) || split[i].equals(dictionary[5]) || split[i].equals(dictionary[6]) || split[i].equals(dictionary[7]) || split[i].equals(dictionary[8]) || split[i].equals(dictionary[9]) || split[i].equals(dictionary[10]) || split[i].equals(dictionary[11]))
{
System.out.println(split[i] + " is valid");
}
else
{
System.out.println(split[i] + " is invalid, please correct");
}
}
}
}