• Post Reply 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
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

For Generics Extra Reading Suggestion Required

 
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

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.

Thanks,
 
Ranch Hand
Posts: 310
1
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prithvi Sehgal wrote:Dear All,

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.

Thanks,



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!


 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.

Best Regards
 
Rajeev Rnair
Ranch Hand
Posts: 310
1
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prithvi Sehgal wrote:

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.

Best Regards



Hi Prithvi,

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>"

Hense the following are invalid:


 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your explanation is very good to clear a lot of doubt.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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.

 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maya Dolas wrote:Hi,
I definitely recommend it not just from exam perspective but also to gain important perspectives on Generics.



Maya thank you very much. That seems a pretty valuable insight. I have noted it down. I am definitely going to check
it. Thanks again.

Best Regards,
 
Sheriff
Posts: 9693
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was also very bad at generics in the beginning, the resources I used (in addition to K&B) were Sun's Tutorial and Generics FAQ...
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Ankit,

Thank you very much. I really appreciate that you shared your experience with me. Now i am at peace, i will concentrate more harder.

Best Regards,
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic