I'm trying to compare the values of the boolean (all of which are 0
) to the values of this string array data[] = "1,0,0,0,0,0,0,0,0,0,0,0,1"
. This is my code:
recipeIngrediants = new boolean[numberOfCuisines][numberOfIngrediants];
int i = 0;
while(file.hasNextLine()){
String temp = file.nextLine();
String[] data = temp.split(",");
for(int j=0; j < recipeIngrediants.length; j++){
String c = data[j];
if(c == "1"){
recipeIngrediants[i][j] = true;
}
else{
recipeIngrediants[i][j] = false;
}
}
i++;
}
I get an error saying that it is a type mismatch. EDIT: Fixed the type mismatch error but it still gives me a value of false for all values in the boolean
Question:
How else can I compare these values to get the 2D array of recipeIngrediants
to equal true
at whatever position in data
has a 1
?