Array list
Hi, I want to limit ArrayList to 10.
I want maximum 10 customer entries
import java.util.ArrayList;
import java.io.*;
publicclass Customers
{
ArrayList<BankCustomer> InvestCustomers;
publicvoid addCustomer()
{
InvestCustomers =new ArrayList<BankCustomer>( );
Please how can I do that, using ArrayList
Thx AYMF
Just don't add more than 10 customers.
If you want to enforce that programatically, then try extending ArrayList (I think it's final, but can't check right now) and override the add to impose your facile limitation...
If that doesn't work wrap ArrayList in a DodgyArrayList... make sure it implements all the same interfaces as ArrayList. Yuk!
Failing that refer to option 1. Just knobble your CustomerManager to not add more than 10 customers.