I am learning JAVA and for one of my exercice I am using DrJAVA IDE and I can’t find issue to the following code whose error on console is “This class does not have a static void main method accepting String[].”
abstract class Forme {
protected String couleur;
protected int x, y;public Forme(String couleur, int x, int y) {
this.couleur = couleur;
this.x = x;
this.y = y;
}public abstract String toString();
}class Cercle extends Forme {
private int rayon;public Cercle(String couleur, int x, int y, int rayon) {
super(couleur, x, y);
this.rayon = rayon;
}public String toString() {
return “<circle cx=”” + x + “” cy=”” + y + “” r=”” + rayon + “” fill=”” + couleur + “” />”;
}
}class Rectangle extends Forme {
private int width, height;public Rectangle(String couleur, int x, int y, int width, int height) {
super(couleur, x, y);
this.width = width;
this.height = height;
}@Override
public String toString() {
return “<rect x=”” + x + “” y=”” + y + “” width=”” + width + “” height=”” + height + “” fill=”” + couleur + “” />”;
}
}class TestFormes {
public static void main(String[] args) {
Cercle cercle = new Cercle(“red”, 50, 50, 20);
Rectangle rectangle = new Rectangle(“blue”, 10, 10, 100, 50);System.out.println(cercle);
System.out.println(rectangle);
}
}
No problem regarding compilation but running is failed. I have tried to work on the main method but nothing WORKS,
thi789 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.