SCJP, SCWCD, SCBCD, SCEA 5
SCJP, SCWCD, SCBCD, SCEA 5
Mohamed Farouk wrote:Yes your right I am constructing List<Shape> list = new ArrayList<Shape>(); But if List<Shape> is different from List<Circle> how am i able to add to the ArrayList<Shape> a object of type List<Circle>.
Yes again if I pass List<Circle> = new ArrayList<Circle> the compilation fails on drawAll method. But If I change the drawAll to accept a bounded Shape then works?
SCJP, SCWCD, SCBCD, SCEA 5
Like you said List<Circle> can be added to List<Shape> as circle is a shape?
Mohamed Farouk wrote:List<Object> ls = new ArrayList<Object>(); // 1
List<String> lo = ls; // 2
and
List<String> ls = new ArrayList<String>(); // 1
List<Object> lo = ls; // 2
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Yes again if I pass List<Circle> = new ArrayList<Circle> the compilation fails on drawAll method. But If I change the drawAll to accept a bounded Shape then works?
What's a year in metric? Do you know this metric stuff tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|