Jump to content
xisto Community
Sign in to follow this  
Simba49

What Is Wrong With This?

Recommended Posts

I did the javac heater.java thing (I have tried different letter cases)

Then I typed java Heater (using different cases again)

I keep getting this error:
Exception in thread "main" java.lang.NoSuchMethodError: main.

This is the code, which basically follows the bicycle tutorial, I tried copying and pasting that, but still had the same problem.

class Heater {int power = 0;int steam = 0;void changePower(int newValue) {power = newValue;}void changeSteam(int newValue) {steam = newValue;}void printStates() {System.out.println("power:"+power+" steam:"+steam);}}class Heater1 {public static void main(String[] args) {//create two heatersHeater heat1 = new Heater();Heater heat2 = new Heater();//methods for the two heatersheat1.changePower(3);heat1.changeSteam(20);heat1.printStates();heat2.changePower(1);heat2.changeSteam(3);heat2.printStates();}}

BTW the tabs are where they should be.

Notice from WeaponX:
You MUST include the CODE tags whenever you are posting any kind of code, especially if they are chunks of code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.