Welcome to Dream.In.Code
Become a Java Expert!

Join 150,135 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,213 people online right now. Registration is fast and FREE... Join Now!




Printing Method

 
Reply to this topicStart new topic

Printing Method

AngelProgram78
2 Aug, 2008 - 06:56 PM
Post #1

New D.I.C Head
*

Joined: 2 Aug, 2008
Posts: 3

Hi,
I created a contructor called Account but is showing some error messages:

CODE

public class Account {
    
    private String accID;
    private String accountholders[] = new String[3];
    private String address;
    private Double balance;
    //Account Constructor holds accounts information
    public Account(String newAccount, String[] newAccountHolders, String address, Double newBalance)
    {
        accID = newAccount;
        accountHolders = newAccountHolders;
        address = newAddress;  
        balance = newBalance;
    }
    
    public boolean printDetails(Account[] current)
    {
      Account arrayAccount = new Account[4];//Mismatch cannot convet from Account[] to Account
      arrayAccount[0] = getAccID();
      arrayAccount[1] = getAccountHolder();
      arrayAccount[2] = getAddress();
      arrayAccount[3] = getBalance();
    
    
    }  
    
    
    
}
//i created all the setters and getters (i didnt include those so it does make long)
--------------------------------------------------------------------------

and there is another class called Holders where
i need to print the summurize details in Account from this class
private ArrayList<Account> accounts;
    
    public accountHolders()
    {
        accounts = new ArrayList<Account>();
    }

public void printAccountDetails()
    {
        for (int i = 0; i < accounts.size(); i++)
        {
            Account myAccount  = accounts.get(i);
            System.out.println(myAccount.printAccountDetails());//The method printDetails()) is undefined fot the type Account
        }
    }


Edited by pbl to add the code tag please code.gif

This post has been edited by pbl: 2 Aug, 2008 - 07:25 PM
User is offlineProfile CardPM
+Quote Post

redzuan
RE: Printing Method
2 Aug, 2008 - 07:50 PM
Post #2

New D.I.C Head
*

Joined: 21 Jul, 2008
Posts: 47


My Contributions
QUOTE(AngelProgram78 @ 2 Aug, 2008 - 07:56 PM) *

Hi,
I created a contructor called Account but is showing some error messages:

CODE

public class Account {
    
    private String accID;
    private String accountholders[] = new String[3];
    private String address;
    private Double balance;
    //Account Constructor holds accounts information
    public Account(String newAccount, String[] newAccountHolders, String address, Double newBalance)
    {
        accID = newAccount;
        accountHolders = newAccountHolders;
        address = newAddress;  
        balance = newBalance;
    }
    
    public boolean printDetails(Account[] current)
    {
      Account arrayAccount = new Account[4];//Mismatch cannot convet from Account[] to Account
      arrayAccount[0] = getAccID();
      arrayAccount[1] = getAccountHolder();
      arrayAccount[2] = getAddress();
      arrayAccount[3] = getBalance();
    
    
    }  
    
    
    
}
//i created all the setters and getters (i didnt include those so it does make long)
--------------------------------------------------------------------------

and there is another class called Holders where
i need to print the summurize details in Account from this class
private ArrayList<Account> accounts;
    
    public accountHolders()
    {
        accounts = new ArrayList<Account>();
    }

public void printAccountDetails()
    {
        for (int i = 0; i < accounts.size(); i++)
        {
            Account myAccount  = accounts.get(i);
            System.out.println(myAccount.printAccountDetails());//The method printDetails()) is undefined fot the type Account
        }
    }





show ur full coding pleaz...maybe i can help

User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Printing Method
2 Aug, 2008 - 09:36 PM
Post #3

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
It would also help if you tell us the actual error messages you are getting. Otherwise we are left guessing. Thanks! smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 01:57AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month