I was reading K&B generics chapter 7. I finished with it and tried solving the exercise. I feel i am lacking in a lot of
concepts i suppose.
For example syntax like this
Tricky syntax. I am making a lot of mistakes when i am encountering questions like Generic typing. Can someone give me
some pointers towards good reference for further reading.
If not generics suggestion, then any guidance, because i am really performing bad in Generics. Advice needed.
Hi Prithvi, have you tried Examlab questions? It do have a lot of good generics questions. Please go through the explanations and do lot of small code where concepts are not clear.
I answered wrong the above question first time!
So i am not the only one in this league. Glad you joined me as a first timer also Rajeev.
Rajeev, can you explain me what the above statement really means? It's such a weird syntax.
It is same like
Think about List<E> list = new ArrayList<E>();
Here "E" can be anything, String, or Integer or even List<Integer>
The tricky part is what ever E is, the right hand side has to be ArrayList<E>(), not ArrayList<subtype of E>(), not ArrayList<supertype of E>
If we define E as Integer
Now let us change "E" to "List<Integer>"
Here you go!
Since "E" is "List<Integer>" here, you cannot replace right hand side with anything other than "E" which is "List<Integer>"
When I appeared for SCJP5, I was weary about the generics. After passing the exam I tried digging into it more and found a very good link and FAQ article specifically for Generics. Just google
Angelika Langer generics FAQ and you should find it. I definitely recommend it not just from exam perspective but also to gain important perspectives on Generics.