# Why does it say the boolean cannot be de-referanced?

**807603**Nov 11, 2007 9:39 PM

I'm writing Conway's Game of Life for my class in Java,

Here's the section of code that's giving me trouble:

Here's the section of code that's giving me trouble:

```
public static void give_life(boolean[][]grid_of_life, int x, int y)
{
System.out.println("width = " +x);
System.out.println("height = "+y);
int counter = 0;
for(int i = 0;i<x;i++)
{
for(int j = 0;j<y;j++)
{
if(grid_of_life[i][j] == true)
{
if(grid_of_life[i][j+1] == true) counter++;
if(grid_of_life[i+1][j+1] == true) counter++;
if(grid_of_life[i+1][j] == true) counter++;
if(grid_of_life[i+1][j-1] == true) counter++;
if(grid_of_life[i][j-1] == true) counter++;
if(grid_of_life[i-1][j-1] == true) counter++;
if(grid_of_life[i-1][j] == true) counter++;
if(grid_of_life[i-1][j+1] == true) counter++;
if(counter<=1) grid_of_life[i][j].equals(false); //ERROR: says 'boolean cannot be dereferanced
if(counter>=4) grid_of_life[i][j].equsls(false);//ERROR: says 'boolean cannot be dereferanced
counter = 0;
}
else
{
if(grid_of_life[i][j+1] == true) counter++;
if(grid_of_life[i+1][j+1] == true) counter++;
if(grid_of_life[i+1][j] == true) counter++;
if(grid_of_life[i+1][j-1] == true) counter++;
if(grid_of_life[i][j-1] == true) counter++;
if(grid_of_life[i-1][j-1] == true) counter++;
if(grid_of_life[i-1][j] == true) counter++;
if(grid_of_life[i-1][j+1] == true) counter++;
if(counter == 3) grid_of_life[i][j].equals(true);//ERROR: says 'boolean cannot be dereferanced
counter = 0;
}
}
}
// check the result
for(int i = 0;i<x;i++)
{
for(int j = 0;j<y;j++)
{
System.out.println("Final State at: " +(i+1)+ " " +(j+1)+ " = " + grid_of_life[i][j]);
}
}
return;
}
```

- 49 Views
- Tags: none (add)