Mam taką klasę:
import java.awt.Graphics;
public class Cegielka {
private int x, y;
private int w, h;
private boolean s;
public Cegielka()
{
s = true;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public int getW()
{
return w;
}
public int getH()
{
return h;
}
public boolean getS()
{
return s;
}
public void setX(int nX)
{
x = nX;
}
public void setY(int nY)
{
y = nY;
}
public void setW(int nW)
{
w = nW;
}
public void setH(int nH)
{
h = nH;
}
public void setS(boolean bS)
{
s = bS;
}
public void wyswietlCegielke(Graphics g)
{
g.fillRect(x, y, w, h);
}
}
W klasie innej wywołuję taką metodę:
public Cegielka [][] zbudujCegielki(int xE, int yE)
{
Cegielka [][] c = new Cegielka [10][20];
double ax = 0.005 * xE;
double ay = 0.04 * yE;
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 20; j++)
{
c[i][j].setX((int)(ax));
c[i][j].setY((int)(ay));
c[i][j].setW((int)(0.04 * xE));
c[i][j].setH((int)(0.02 * yE));
ax += 0.05 * xE;
}
ay += 0.03 * yE;
ax = 0.005 * xE;
}
return c;
}
I JAVA mówi, że c jest nullem. Czemu?