Ok so here's my code. It has to check if all the array word members of "this" and "wca" array are same.
If theyre the same i need true.. But if only one of them is wrong it has to give false.
I know this code is wrong, i use the wordEqual = true or false lines at wrong places. I can't seem to solve it
If one of the members is wrong, i think it will go to the next member and get the boolean as true again.
I thought maybe i could break the loop if its an "else", but im not sure if this is completely right. Help please?
private boolean wordsEqual (WordCountArray wca){
boolean wordsEqual = false;
for (int i = 0; i < wca.size(); i++) {
if (this.getWord(i).equals(wca.getWord(i))) {
if (this.getIndex(getWord(i)) == (wca.getIndex(getWord(i)))) {
wordsEqual = true;;
}
else {
break;
}
}
else {
break;
}
wordsEqual = true;
}
wordsEqual = false;
return wordsEqual;