Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: help!!

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help!!

    Hi, I am a new in java and I really need help in this one. I tried to read it and understand it and put the main methods, but I couldn't. I want the output to say the person first and last name then his account number.

    import java.util.Scanner;

    public class BankAccount
    {
    private String customer; // customer's name
    private int accountNum; // bank account number


    //**************************************************

    public void setCustomer()
    {
    this.customer = customer;
    } // end setCustomer

    public void setAccountNum()
    {
    this.accountNum = accountNum;
    } // end setAccountNum

    //**************************************************

    // This method prints a bank account's information.

    public void printAccountInfo()
    {
    System.out.println(
    this.customer + "'s account number is " +
    this.accountNum + ".");
    } // end printAccountInfo
    } // end class BankAccount

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,075
    Thanks
    47
    Thanked 2,147 Times in 2,120 Posts

    Default Re: help!!

    What happens when you compile and execute the code?
    Copy the full text of any error messages and paste it here.

    If the program executes without error but the output is wrong, copy the full contents of the console window, paste it here and add some comments saying what is wrong with it.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: help!!

    It all right when I compiled. when I run it, it says there is no main methods!

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,075
    Thanks
    47
    Thanked 2,147 Times in 2,120 Posts

    Default Re: help!!

    there is no main method
    To be able to execute a class with the java command it must have a main() method.

    Take a look at the tutorial on how to execute a java class:
    "Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application)

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.