why this pogram is giving error i am not able to understand.as per my understanding put interface is put as extends oirrespective of implements while using collections and generics.
package generics;
import java.util.ArrayList;
import java.util.List;
public class Ques04 {
public static void main(
String[] args) {
List
<? extends Instrument> allInstruments = new ArrayList<Instrument>();
// -->X
allInstruments.add(new Guitar());
allInstruments.add(new Violin());
}
}
interface Instrument {
public void play();
}
class Guitar implements Instrument {
public void play(){
System.out.println("Playing Guitar.");
}
}
class Violin implements Instrument {
public void play(){
System.out.println("Playing Violin.");
}
}