i have 2 classes:
public class A {
public int min, max;
public A(int min_arg, int max_arg)
{
min = min_arg;
max = max_arg;
}
public int getMin()
{
return this.min;
}
public int getMax()
{
return this.max;
}
}
public class B
{
private final boolean[] myBoolean;
private final A testObject;
public B(A testObject)
{
// I want to do something like this:
for(int i = testObject.min(); i != testObject.max(); i++)
{
myBoolean[i] = false;
}
}
}
I want to initialize the Array "myBoolean" in the class B and set all Values to false. The problem is, that it won't let me do it. All it says is that the blank final field "myBoolean" may not be initialized. I've seen that there's a function called Arrays.fill(array, true/false); but that doesn't help me either. Does someone know a way to initialize the Array myBoolean with the min->max from class A? I know that
private final boolean[] myBoolean;
has no size, the size should be the min->max from the class A object. I just can't find a way to do that.