java - Using enhanced for-loop to retrieve data from two ArrayLists -


I have a question about one of the (possibly many) simple problems involved in this.

The idea of ​​code is to list all customers with their accounts, such as my example:

  Customer 1 account 1 remaining account 2 remaining customer 2 account 3 remaining account 4 Balance  

.. and so on. The problem is that the code that is used (shown below) works with the intention of the customer first, showing all of its accounts, but it closes there, even if customer 2 is present in the database Will not print.

  public string allAccounts () {for (Customer customer: Customer) {String clientInfo = ""; ClientInfo = clientInfo + client.getCust () + "\ n \ n"; (Account account: customer.accounts) {clientInfo = clientInfo + account.getAccinfo () + "\ n"; } Return customer INFO; } Return "not in use"; }  

I can add that the customer The customer gets the name of the customer, and that account. GetAccinfo account-number and balance of account get. And since it first acts virtual for the customer, I think this task is a problem with the loop rather than the self.

Any help would be greatly appreciated.

Edit: Thank you very much for all the quick and good answers! much appreciated!

  • a stringbiller init in.gc. For sb outside of (customer ... loop,
  • return customer INFO to sb.append Change in (ClientInfo)
  • Replace "not in use" with back to sb.toString ().) Length == 0? "Not in use": Sb.toString ();

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -