Reputation: 23
I Have
public class SongListView<T> extends ListView<T>
How Can I specify that the Generic Type T is to be a Song Object and no other object?
Upvotes: 0
Views: 61
Reputation: 4471
public class SongListView extends ListView<Song> {...}
you can add to ListView
only Song-instance (can not add heirs of Song.class
)
ListView<Song> songListView = new SongListView();
also you can not assign SongListView
to generic reference of other heirs of of Song.class
class LongSong extends Song {...}
ListView<LongSong> songListView = new SongListView(); //Incompatible types.
Upvotes: 1