Array List in java

by rajesh 2009-12-30 16:46:32

JDK 5.0 supports typed array list. That is an arraylist of specific type

Syntax:
ArrayList list = new ArrayList();


Example:


    Seller sel = new Seller();
Seller sel2 = new Seller();
    Buyer buy = new Buyer();
  
    // declare an array list of type Seller
    ArrayList list = new ArrayList();
    list.add(sel); // will be added
    list.add(buy);  // will return an error
list.add(sel2); // will be added




Tagged in:

1219
like
0
dislike
0
mail
flag

You must LOGIN to add comments