I have made a class called Iset that takes integers and modifies it's boolean array's index equivalent to the integer to true.
e.g. If I pass an integer 1 then the boolean array setI[1] is turned to true.
I have a method called include that returns true if the provided integer is in there and false if it isn't. However no matter what I do I always get true. I have made sure that everything in the array is set to false and I add in a number further up the code. Obviously I'm missing something really obvious here:
public class Iset {
public int size;
boolean[] setI;
Iset(int a) {
this.size = a;
this.setI = new boolean[size];
}
public boolean include(int i) {
for (int n = 0; n <= size; n++) {
if (setI[n]== setI[i]){
return true;
}
}
return false;
}
}
setI? What issize? Show us the code that fillssetI.takes integers and stores them in a boolean arrayyou should rethink this. What is about an int array ?booleanarray? And how exactly are you doing that?