Page 2 of 2 FirstFirst 12
Results 21 to 28 of 28
  1. #21
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Is NewAccount an inner class? If so, I strongly suggest that you don't do this. Put it in its own file. Also, shouldn't the class be named "Account" not "NewAccount"?

    edit: looks like you have a bunch of inner classes. Don't do this unless you have a compelling reason to do so (you don't). My recommendation is for your own good.

  2. #22
    Xystus777 is offline Member
    Join Date
    Jan 2009
    Posts
    22
    Rep Power
    0

    Default

    did you look at my code? I'm confused, what is an "inner class". I have two other classes I believe, NewAccount and Transactions. I suppose I could just call it Account. Correct. Any helpful ideas, I'm not understanding what you mean by putting it in it's own file?

  3. #23
    Xystus777 is offline Member
    Join Date
    Jan 2009
    Posts
    22
    Rep Power
    0

    Default

    Okay, so I guess I created an "external" class or whatever. And called it "Account", and it looks like that error went away. First off, why would the error go away now? What's wrong with an inner class? I'm making progress, thanks for staying up with me on this one.

  4. #24
    Xystus777 is offline Member
    Join Date
    Jan 2009
    Posts
    22
    Rep Power
    0

    Default

    Do you have an AIM name I could contact you at sometime?

  5. #25
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    The current structure of your program consists of one outer class called ATMMachine, and tucked inside of this class are two inner classes, NewAccount and Transaction:
    Java Code:
    public class ATMMachine  // outer class
    {
      public static void main(String[] args)
      {
        // bunch of code
      }
    
      // inner class 1
      class NewAccount
      {
        // bunch of code
      }
    
      // inner class 2
      class Transaction
      {
        // bunch of code
      }
    }
    I'm suggesting that you use three outer classes like so:
    Java Code:
    public class ATMMachine  // outer class
    {
      public static void main(String[] args)
      {
        // bunch of code
      }
    }
    Java Code:
    public class NewAccount
    {
      // bunch of code
    }
    Java Code:
    public class Transaction
    {
      // bunch of code
    }

  6. #26
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Xystus777 View Post
    Okay, so I guess I created an "external" class or whatever. And called it "Account", and it looks like that error went away. First off, why would the error go away now? What's wrong with an inner class? I'm making progress, thanks for staying up with me on this one.
    If you kept with inner classes, you'd have to use some unwieldy statements like this to get things to work:
    Java Code:
        NewAccount[] account = new NewAccount[50];
        for (int i = 0; i < account.length; i++)
        {
          account[i] = new ATMMachine().new NewAccount();
        }
    because inner classes can't stand on their own. They have to be created on top of the outer class. Again, don't do this unless you have a reason to do so. Later on when you create GUIs, you'll likely use inner classes a lot and even anonymous inner classes, but now is not the time to do this.

    And no, I don't do AIM. Most of us have jobs and families that take up most of our time and efforts, myself included. Best of luck.

  7. #27
    Xystus777 is offline Member
    Join Date
    Jan 2009
    Posts
    22
    Rep Power
    0

    Default

    Alright, I got it to get a name and print it. I don't "need" to print it, but I was just testing it, and it printed:

    "account[accountsOpen].setName(name);" Thanks man!!!

  8. #28
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 0
    Last Post: 02-12-2009, 12:12 AM
  2. Applet buttons
    By h3ckf1r3 in forum Java Applets
    Replies: 6
    Last Post: 09-22-2008, 10:15 PM
  3. How to use Radio Buttons
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-25-2008, 03:26 PM
  4. How to use SWT Buttons
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:44 PM
  5. information from a textfields
    By bbq in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-28-2007, 06:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •