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

[691 byte] By [AsYourMindFliesa] at [2007-11-27 5:37:18]
# 1

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.

corlettka at 2007-7-12 15:09:13 > top of Java-index,Java Essentials,New To Java...