How to fix it...
Code:
boolean[] array = new boolean[20];
....or inside a method (or the constructor):
boolean[] array;
IntegerSet()
{
array = new boolean[20];
...
}
There is also another error in your code, as you try to access an instance
variable from the static scope of main.
Instance variables can only be used in the context of the instance. Either
change the variable to be static, and use it in static context, or create an
instance.
public static void main(String[] arg)
{
IntegerSet s = new IntegerSet();
System.out.print( "Values of the array: [ ");
for (int i = 0; i < s.array.length; i++)
{
System.out.print( s.array[i] + " " );
}
System.out.println("]");
}
Bookmarks