java penname.java
error: can’t find main(String[]) method in class: Pen
class Pen {
String color;
public void printColor() {
System.out.println("The color of this Pen is " + this.color);
}
}
public class penname {
public static void main(String args[]) {
Pen p1 = new Pen();
p1.color = "blue";
Pen p2 = new Pen();
p2.color = "black";
Pen p3 = new Pen();
p3.color = "red";
p1.printColor();
p2.printColor();
p3.printColor();
}
}
this code is getting compiled correctly but upon running it is showing me the above error
New contributor
Swathi D Gowda is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.