public class TestAcc { public static void main(String args[]) { Account[] arr = new Account[3]; arr[0] = new Account(233445678, 45.0); arr[1] = new Account(143741234, 65.0); arr[2] = new Account(453850357, 85.0); displayAccounts(arr); } static void displayAccounts(Account[] acc) { System.out.println("Account no. Balance"); System.out.println(); for (int i = 0; i < acc.length ; i++) { System.out.println(acc[i].id() + " " + acc[i].balance() ); } } }