How do I compare a string in an array to a string?
- by user1641312
EDIT: IT'S FIXED, THANKS FOR THE HELP!
So basically I have an array of strings, a question and an answer
public static String[][] triviaData = {
{"Question2", "Answer1"},
{"Question2", "Answer2"},
{"Question3", "Answer3"},
};
And I am trying to make a method that validates an entered input, lets call the entered input enteredAnswer. enteredAnswer is stored as a String.
I am trying to validate that the enteredAnswer is the same as the second index of the array.
if (enteredAnswer.equalsIgnoreCase(triviaData[Config.CurrentQuestion][1])) {
This is the code I tried, but I get the error "Cannot invoke equalsIgnoreCase(String) on the array type String[]"
I am a beginner programmer so if you could help me out it would be highly appreciated. Thanks.
enteredAnswer is stored as
public String[] enteredAnswer;