Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide
this week in the
Programmer Certification
forum!
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
Programmer Certification (OCPJP)
Generics Question
temesgen kahsay
Greenhorn
Posts: 4
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi ranchers, i am new to post but i almost read the forum daily. and to come to my question,
why is the line commented as "This line" not working
import java.util.*; class Animal {} class Dog extends Animal {} class Cat extends Animal {} class generics4 { public void addAnimal(List<? super Dog> animals) { animals.add(new Dog()); animals.add(new Animal());//This line } public static void main(String[] args) { List<Animal> animals = new ArrayList<Animal>(); animals.add(new Dog()); animals.add(new Dog()); animals.add(new Cat()); generics4 doc = new generics4(); doc.addAnimal(animals); } }
Henry Wong
author
Posts: 23959
142
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You already asked this exact question yesterday. And it has already been answered.
https://coderanch.com/t/465227/Programmer-Certification-SCJP/certification/Why-not-working
Henry
Books:
Java Threads, 3rd Edition
,
Jini in a Nutshell
, and
Java Gems (contributor)
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Generics.
Whats wrong with this code
Generics problem- why not taking Animal, Object and super of Dog
Doubt in generics
Generics Problem
More...