How to create specific type of arraylist in java?

0 votes
20 views
asked Apr 26 in JAVA by admin (8,115 points)
HI

  Have a Country as class and i want to store in the arraylist, Need help to create arraylist with specific type?

1 Answer

0 votes
answered Apr 26 by anonymous
Hi 

Supose you want an ArrayList to be filled only with Country. If you write:

ArrayList<Country> list = new ArrayList<Country>();
    list.add("A");
    list.add("B");
    list.add("C");
...