public class Circle {
public double x;
public double y;
public double radius;
//write your code here
public Circle(double x) {
this.x = x;
}
public Circle(double x, double y) {
this(x);
this.y = y;
}
public Circle(double x, double y, double radius) {
this(x, y);
this.radius = radius;
}
public Circle() {
this(x, y, radius);
}
public static void main(String[] args) {
}
}
com/codegym/task/task05/task0522/Circle.java:32: error: cannot reference x before supertype constructor has been called
this(x, y, radius);
^
com/codegym/task/task05/task0522/Circle.java:32: error: cannot reference y before supertype constructor has been called
this(x, y, radius);
^
com/codegym/task/task05/task0522/Circle.java:32: error: cannot reference radius before supertype constructor has been called
this(x, y, radius);
^What does this error mean?
Under discussion
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
Charlie Branson
30 January 2020, 02:59
just remove the (x,y,Radius) and it will run through. this is a default constructor that takes no arguments.
0
tony
28 December 2018, 08:38
there is no default constructor in your code:
public Circle() {
}
add it
it should look like this:
+3
Mom Meme
10 December 2018, 18:15
You have to do public void instead of just public
0
DS
29 August 2018, 08:49
Error here
This means that you pass unknown parameters to the constructor. Where did you get them (x, y, radius)? 0
Niket
15 January 2019, 11:58
Please explain what the above code does.
I am still not able to get the concept of "this" inside a constructor.
+1