wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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?
 
Consider Paul's rocket mass heater.
 
subject: can i add any type of collection to Collection<Instrument>
 
Similar Threads
Generics
Generics-compiler error
Regarding Generics !
Generics Prob
Generics for Interface