I am making a quiz with Java, and an error has appeared. When I enter in the right answer, it says it is wrong. Any ideas?
Code:
package revision_project;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;
public class Quiz {
public static void main(String args[]){
String newline = System.getProperty("line.separator");
Scanner input = new Scanner(System.in);
String[] questions = {"What is an integer?", "What does CPU stand for?", "How far can a LAN go?",
"What does LAN stand for?", "Give an example of a WAN.", "What is a syntax error?"};
String[] answers = {"a whole number", "central processing unit", "2km", "local area network",
"internet", "when the programmer enters in incorrect syntax."};
List<String> correct = new ArrayList<String>();
for(int i = 0; i < questions.length; i++){
System.out.println(questions[i] + ": " + newline);
String x = input.nextLine();
x = x.toLowerCase();
if(x == answers[i]){
System.out.println("Correct");
//correct.add("Correct");
} else{
System.out.println("Wrong");
//correct.add("Wrong");
}
}
}
}