shaji kumar

Greenhorn
+ Follow
since Aug 14, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by shaji kumar

Thanks a lot to all of you for your valuable time and effort to make me understand the concept very well .
Thank you all ,

Is there any practical implementation of these declarations or they are just as a valid declaration for the compiler, can we use these declarations in any scenarios .As per my understanding
we cant insert anything except null so in that case we can retrieve only null , so what is the use , if there is any use above my understanding please help me ,Thanks in advance !!!
Thanks a lot henry , can you please explain the below scenario . In the first scenario if i can declare anything which extends animal , there is no compile error but in second scenario if i specifically say Animal i am getting
compile error , i am really not able to understand the concept , in one place it says keep the generic type reference and generic type of the object identical (page no 608 scjp kathy ) but in the first scenario as it is varying still no compile error !!! .

1)List<? extends Animal> list=new ArrayList<Dog>(); //no compiler error


2) List<Animal> list=new ArrayList<Dog>(); //compile error
Thanks a lot rohit jain for your valuable time for clearing my query , i will be really happy if you can provide some small examples for each . Thanking you once again!!!
Which of them are legal declarations ?

1) List<?> list=new ArrayList<Dog>();
2) List<? extends Animal> list=new ArrayList<Dog>();
3) List<?> foo=new ArrayList<? extends Animal>();
4) List<? extends Dog>clist= new ArrayList<Integer>();
5) List<? super Dog>blist=new ArrayList<Animal>();
6) List<? super Animal>dlist=new ArrayList<Dog>();

correct answers are 1 , 2 and 5 , can someone tell what is the use of the correct answers , like where do v apply it .Thanks in advance