| Author |
exam watch (page 604) Generics constructor
|
Pawanpreet Singh
Ranch Hand
Joined: Jun 12, 2005
Posts: 264
|
|
class X { public <X> X(X x){} } could anybody explain me this in detail? Thanks in advance
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
Is the above not the same as the following? I just throw this in for discussion (generics are still puzzling me).
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Pawanpreet Singh
Ranch Hand
Joined: Jun 12, 2005
Posts: 264
|
|
|
What is actual use of T and E and X in generics?
|
 |
Keith Lynn
Ranch Hand
Joined: Feb 07, 2005
Posts: 2341
|
|
T and E are just conventions. T stands for type, and E stands for element. However, you can use valid Java identifiers for the type parameters. I believe that the example in question was an example of what not to do. However, they are pointing out that there is no confusion on the part of the compiler if you use the same identifier for the type parameter as the name of the class and/or the name of the method.
|
 |
Pawanpreet Singh
Ranch Hand
Joined: Jun 12, 2005
Posts: 264
|
|
|
Thanks Keith
|
 |
 |
|
|
subject: exam watch (page 604) Generics constructor
|
|
|