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++ –