aspose file tools*
The moose likes Java in General and the fly likes can i add any type of collection to Collection<Instrument> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "can i add any type of collection to Collection<Instrument>" Watch "can i add any type of collection to Collection<Instrument>" New topic
Author

can i add any type of collection to Collection<Instrument>

Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
i have a collection named
Collection<Instrument> x;

can i add any type of collection x?
any type mean List,Set ,Queue or Map?
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
Be careful: Map is not a subinterface of Collection

You can build an instance of all the classes implementing subinterfaces of Collection (Set,List,Queue...)


Bye,
Nicola
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What happened when you tried? What did you discover in the API documentation?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: can i add any type of collection to Collection<Instrument>