|
I've been having trouble understanding what to do in my Java class (pun totally intended), as my teacher has been assigning lots of programming homework but has very seldom worked with us in class periods to program things.
Whining aside, if anyone knows Java, I'd appreciate some help here:
This is the Cube.java/Cube.class file:
| CODE | public class Cube { private int side; //instance variables public Cube(int s){} //constructor public int getArea() //instance method { return side * side * 6; } public int getVolume() //instance method { return side * side * side; } } |
And this is the CubeUser.java/CubeUser.class file:
| CODE | public class CubeUser { public void main(int argv[]) { Cube cube1 = new Cube(5); Cube cube2 = new Cube(6); Cube cube3 = new Cube(7); cube1.getArea(); cube1.getVolume(); cube2.getArea(); cube2.getVolume(); cube3.getArea(); cube3.getVolume(); } } |
I get this error: java.lang.NoSuchMethodError: main Exception in thread "main" And I have no clue how to fix it. Am I not defining what the main method is? If I'm not, how would I go around doing that? I am a beginner in Java, just trying to get a feel for how things work, so I realize this may be a stupid question for some of you. Any help is appreciated!
--------------------
Quoth the raven, "~teehee~"
|