Compare the index of 2 string arrays Java

anas_eqal

New Member
I'm trying to figure out how to reference the index of 2 string arrays. In the checkAnswer method I can confirm the users input is stored in the capitalArray at index but how do I compare the index of capitalArray == stateArray instead of comparing the strings stored at index \[code\] public static void main{ ... for (int i = 1; i <=10; i++){ System.out.println("What is the capital of " + stateArray[randomQuestion(0)]"?"); answer = in.nextLine(); if (checkAnswer(stateArray, capitalArray, answer) == true) { correct++; } total = i; } } public static boolean checkAnswer(String[]stateArray, String[]capitalArray, String answer) { for (int i = 0; i < stateArray.length; i++) { if (capitalArray.equalsIgnoreCase(answer) && capitalArray == stateArray) { return true; } } return false;}\[/code\]
 
Top