public abstract class CircleShape {
	public double radius;
	public CircleShape(){}
	public CircleShape(double radius) {
		this.radius=radius;
	}

	public void setradius(double radius){
		this.radius=radius;
	}


	public String toString()
	{
		return "radius"+ radius;
	}


	abstract String getDisplayText();
}
public class circle extends CircleShape{
private double area;
public double area()
{
	return radius*radius*3.14;
}

public String getDisplayText()
{
	return super.toString() + area;
}


}
public class testcircle{
	public static void main(String[] args){

circle myCircle = new circle();
myCircle.setradius(5.0);
System.out.println(myCircle.getDisplayText());

}

}

I am getting this error while executing:
exception in thread "main" java.lang.NoSuchMethodError

where am i going wrong?

Recommended Answers

All 7 Replies

Your error message should also indicate which method does not exist. Which one is it complaining about?

Exception in thread "main" java.lang.NoSuchMethodError:main

this is the error which I am getting

Are you executing "testcircle"?

i executed all three:

java testcircle circle CircleShape

There is your problem. You can't execute all three because testcircle is the only one with a main method. On top of that, I don't think you can execute more than one class at once with the java command. Just change it to java testcircle

OMG! you are right....I got the answer..thanks a lot!

Yeah, no problem. Ezzaral basically handed me the easy solution though. :p Mark the thread as solved. . ? (I haven't solved one in a good while. . lol)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.