N
Neroku
Hello, I have a problem calling a constructor inside another
constructor, consider this code:
class Point
{
private final int Y_DEFAULT = 3;
private final int Z_DEFAULT = 5;
private int x,y,z;
Point(int x)
{
this(x,Y_DEFAULT,Z_DEFAULT);
}
Point(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
}
I get these errors whe I try to compile the code above:
cannot reference Y_DEFAULT before supertype constructor has been called
cannot reference Z_DEFAULT before supertype constructor has been called
Does anybody know why this happens?
TIA
constructor, consider this code:
class Point
{
private final int Y_DEFAULT = 3;
private final int Z_DEFAULT = 5;
private int x,y,z;
Point(int x)
{
this(x,Y_DEFAULT,Z_DEFAULT);
}
Point(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
}
I get these errors whe I try to compile the code above:
cannot reference Y_DEFAULT before supertype constructor has been called
cannot reference Z_DEFAULT before supertype constructor has been called
Does anybody know why this happens?
TIA