Adblock breaks this site

What is wrong with this? (trying to follow tutorials)

Discussion in 'Programming General' started by Massive Mage 333, Mar 20, 2007.

  1. Massive Mage 333

    Massive Mage 333 Member

    Joined:
    Jan 21, 2007
    Posts:
    95
    Referrals:
    0
    Sythe Gold:
    0
    What is wrong with this? (trying to follow tutorials)

    I'm trying to follow the tutorials so I just made something up. I saved the file as heater.java

    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 heaters
    Heater heat1 = new Heater();
    Heater heat2 = new Heater();

    //methods for the two heaters
    heat1.changePower(3);
    heat1.changeSteam(20);
    heat1.printStates();

    heat2.changePower(1);
    heat2.changeSteam(3);
    heat2.printStates();

    }
    }

    BTW the tabs are where they should be.
     
  2. kingpin

    kingpin Guru
    Banned

    Joined:
    Jan 21, 2007
    Posts:
    1,178
    Referrals:
    0
    Sythe Gold:
    0
    What is wrong with this? (trying to follow tutorials)

    hmm i will try to figure something out abot this
     
  3. Massive Mage 333

    Massive Mage 333 Member

    Joined:
    Jan 21, 2007
    Posts:
    95
    Referrals:
    0
    Sythe Gold:
    0
    What is wrong with this? (trying to follow tutorials)

    Yeah, I just realized I am a moron. Figured out the problem myself. Please lock.
     
  4. im the pjer

    im the pjer Active Member
    Banned

    Joined:
    Apr 29, 2007
    Posts:
    175
    Referrals:
    0
    Sythe Gold:
    0
    What is wrong with this? (trying to follow tutorials)

    add my msn
     
  5. im the pjer

    im the pjer Active Member
    Banned

    Joined:
    Apr 29, 2007
    Posts:
    175
    Referrals:
    0
    Sythe Gold:
    0
    What is wrong with this? (trying to follow tutorials)

    add me :D
     
  6. im the pjer

    im the pjer Active Member
    Banned

    Joined:
    Apr 29, 2007
    Posts:
    175
    Referrals:
    0
    Sythe Gold:
    0
    What is wrong with this? (trying to follow tutorials)

    why dont u add me >S
     
  7. Doombringe1

    Doombringe1 Forum Addict

    Joined:
    May 19, 2007
    Posts:
    471
    Referrals:
    0
    Sythe Gold:
    0
    What is wrong with this? (trying to follow tutorials)

    Hey what was it that was wrong with the code exactly. When i tryed to go through it i couldnt find anything. Probully because im half asleep. But please tell me because im dieing to know.
     
  8. x⁹

    x⁹ Guest

    Referrals:
    1
    What is wrong with this? (trying to follow tutorials)

    Nothing wrong with the code. It was what he was typing into the console that caused the problem.
     
< Java Newbie - coding | Help, Plz?? >


 
 
Adblock breaks this site