public static String[] wordArray(int wordAmount){
String[] words = new String[wordAmount];
Scanner input = new Scanner(System.in);
for(int i = 0; i < wordAmount; i++){
System.out.print("Enter a word: ");
words[i] = input.nextLine();
for(int j = 0; j < wordAmount; i++){
if(words[i].contains(words[j]) & (i != j)){ ///////////////////
System.out.print("The word you entered has already been entered, enter a new word: ");
words[i] = input.nextLine();
}
}
while(words[i].length() > 10 | words[i].length() <= 1 | words[i].contains(" ")){
System.out.print("The word you entered has been rejected, enter a new word: ");
words[i] = input.nextLine();
}
}
return words;
}
The line of code with all the slashes behind it isn't working(only put the slashes there to indicate which line im having problems with), im not to sure why its not working and I've rearranged the code many times and nothing has worked thus far. If anyone knows why its not working I would greatly appreciate a solution to this problem.
Error message: Exception in thread "main" java.lang.NullPointerException
Aucun commentaire:
Enregistrer un commentaire