• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

In generics what is mean by <E> <T> <? extends >?

 
lakmal padmakumara
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Explain these three occasions with a small example ?Or if you can please explain it literally .I'm having some trouble to read and understand a code ,because these signs are every where .Im checking sun tutorials also ,But I know It will help me ia lot if you can describe with your own words ! Please help !
 
Nicolas Kal
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lakmal,

List<Base1> : A list that holds elements of type Base1
List<T extends Base1> : A list that holds elements that are either of type Base1 or they extends Base1.class

When applied to class:
In the following abstract class there are two infer types, notice that the H extends Model is used and that the H is used in the abstract class



When a concrete class extends the abstract class the H will be "replaced" by the Hotel class



It is a good design aproach when you have to deal with common functionalities but you have to work with different implementations

Regards,
Nicolas
 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google for Angelika Langer Java Generics FAQ; Angelika Langer's website is an excellent resource, but it has some things on not easy to understand. There is a good chance there will be a question just like what you asked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic