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;
}
帶有所有斜槓的代碼行不起作用(只是在那裏指出哪些斜線表示我有問題)im,不知道爲什麼它不工作,我重新安排了很多次的代碼,到目前爲止沒有任何工作。如果有人知道爲什麼它不工作,我將不勝感激解決這個問題。如果聲明條件不起作用
錯誤消息:異常在線程「主」顯示java.lang.NullPointerException
嗨德文,我建議你也哪種語言你的工作在讓更多的人來幫助你的標籤。 – micstr
@aidan該鏈接適用於C++ –