Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Newby needs help

  • 12-05-2007 7:15pm
    #1
    Registered Users, Registered Users 2 Posts: 271 ✭✭


    Hi peeps the names Shane never mind that stupid name i created, anyway i just started learning Java off this website and i cant get this compile


    // Create_account creates an account, deposites money, and returns an account
    public account create_account(double balance)
    {
    account my_account;

    // Instantiate a new ob
    my_account = new account (balance);

    // Call the deposite method of your object my_account
    my_account.deposite (25.00);

    return account;
    }


    Heres the link for the website im learning from http://www.javacoffeebreak.com/java102/java102.html

    Can you tell me why this is not working, tnx


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    What error message are you getting from the compiler? Is that all the code?


  • Registered Users, Registered Users 2 Posts: 271 ✭✭Starfox


    What error message are you getting from the compiler? Is that all the code?


    Error message - 'class' or 'interface' expected

    it never stated on the website i had to place this in the code


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Ok.

    What you have here is called a method. Its a block of code that you will call upon to do a task at a later time. Methods have to go inside Classes in order to be able to work. If you look further down the page you linked to, you will see the example Account class, with a number of example methods inside it.

    The reason you are getting an error is because you have written a method that is not inside a class.


  • Registered Users, Registered Users 2 Posts: 271 ✭✭Starfox


    Ok.

    What you have here is called a method. Its a block of code that you will call upon to do a task at a later time. Methods have to go inside Classes in order to be able to work. If you look further down the page you linked to, you will see the example Account class, with a number of example methods inside it.

    The reason you are getting an error is because you have written a method that is not inside a class.


    oh right i see now, thanks for help:D


Advertisement