0
public class test {
public static void main(String[] args) {
    double[] d=new double[500];
    for (int i = 0; i <500 ; i++) {
        d[i]= Integer.MAX_VALUE;
    }
    boolean[] disco=new boolean[500];
    for (int i = 0; i <500 ; i++) {
        disco[i]= false;
    }
    disco(5)=true;
}

}

I get an "method call expected" error when trying to change a value in the disco array. Could someone explain to me why that is?

krise
  • 485
  • 1
  • 10
  • 22

2 Answers2

1

To access an item in an array at a particular position use the square brackets notation.

disco[5]=false;

not

disco(5)=false;
bhspencer
  • 13,086
  • 5
  • 35
  • 44
0

You should use disco[5] not disco(5).

When you put () after disco, java is looking for a method disco that does not exist. To access an index of an array, you use [], square brackets.

MMelvin0581
  • 509
  • 6
  • 20