0

How to number an array?

This is part of a bank program. I have an array Account[] with the capacity of 100, i have to save and number the accounts i have as an integer. I don't have to fill up all 100. How do i do that? Account[] = 100; And then?

17th Nov 2019, 10:04 PM
M.J.
M.J. - avatar
1 Antwort
+ 3
so you have 2 variables. Account[] accounts = new Account[100]; int accountAmount = 0; adding an account would look something like this: void addAccount(Account ac){ accounts[accountAmount] = ac; accountAmount++; } hope I understood your question right 😅
17th Nov 2019, 11:22 PM
Anton Böhler
Anton Böhler - avatar