Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Java output problem; cannot connect methods

    Hey, I'm having problems getting my program to output. I've tried numerous ways, but I'm still pretty new at this. The rate at which my professor teaches isn't really helping, so it would be greatly appreciated if I could get some help. (I don't see a spoiler tag button, so I'm just going to post this, it's not very long)

    import javax.swing.JOptionPane;

    public class TestAccount {
    public static void main(String[] args){

    //Accounts array
    Account[] accounts = new Account[4];
    accounts[0] = new Account("111222333",1500.75,.25,5175.42);
    accounts[1] = new Account("111222334",501.80,.15,150.32);
    accounts[2] = new Account("111222335",1122.56,.225,3007.78);
    accounts[3] = new Account("111222336",1201.77,.25,2004.35);
    }
    //Loop and Display
    public void showMessage(Account[] accounts) {
    String output = "";
    for (int i=0; i<accounts.length; i++){
    output += accounts[i].toString() + "\n";
    }

    JOptionPane.showMessageDialog(null, output, "Current Account", JOptionPane.PLAIN_MESSAGE);
    }

    }

    Everything works but the output part, so if you have any hints...

  • #2
    Regular Coder brad211987's Avatar
    Join Date
    Sep 2005
    Location
    Ohio
    Posts
    631
    Thanks
    10
    Thanked 50 Times in 50 Posts
    You are not calling your showMessage method anywhere. At the end of your main method try:

    Code:
    showMessage(accounts);


  •  

    Tags for this Thread

    Posting Permissions

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