I always get this error whenever i compile the code:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
I know that the error is in the array chosen[], but i think I initializated it correctly. Can anyone tell where the problem is?
public boolean[] chosen=new boolean[n];
public void clear() {
for (int k= 0; k < n; k++)
{
chosen[k] = false;
}
I saw other answers on the same question , but none of them was helpful. Thank you.