I have the following methods that I wrote are array and boolean methods. I was wondering how, if possible, can I convert the array method into an ArrayList one.
public int[] letsMap(){
int[] iArray = new int[maxBagSize + 1];
int w;
for(int i = 0; i < ourBags.size(); i++){
w = ourBags.get(i).foo;
iArray[w]++;
}
return iArray;
}
.
public boolean comp(SearchState search){
boolean cool = false;
if(search.unBaggedItems.equals(this.unBaggedItems)){
int[] mine = letsMap();
int[] theirs = search.letsMap();
cool= true;
for(int i = 0; i < maxBagSize; i++){
if(mine[i] != theirs[i]){
cool = false;
break;
}
}
}
return cool;
}
ourBagsmeets or exceeds the length of the array, you'll get a runtime exception. Also, what does your methodcomphave to do with your question?