I am currently working on a quiz game. In the following public void Run(), I want to validate the user input String answerwith the correct answers:
answersList.forEach(new String.
I am trying to do this with a boolean. But I receive this error message: "Cannot resolve constructor 'String(boolean)'. How do I do to solve this issue?
Initialization of the private volatile boolean:
class Broadcaster extends Thread {
private volatile boolean check_point = true;
public boolean getFlag() {
System.out.println("getFlag is running");
return this.check_point;
}
And after BufferedReader, PrintStrem and so on...
public void run() {
while (true) {
try {
List<String> answersList = new ArrayList<>();
try (Stream<String> answersStream = Files.lines(Paths.get(answersFile))) {
answersList = answersStream
.map(String::toLowerCase)
.collect(Collectors.toList());
} catch (IOException a) {
a.printStackTrace();
System.out.println("The timer isn't working correctly");
}
if (answersList.forEach(new String(equals(answer)))) { //ERROR MESSAGE
write.println("Right Answer");
points++;
check_point = true;
} else {
write.println("Wrong Answer");
check_point = false;
}
} catch (Exception e) {
System.out.println("Some problem with the validation");
}
}
}
}