aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes exam watch (page 604) Generics constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "exam watch (page 604) Generics constructor" Watch "exam watch (page 604) Generics constructor" New topic
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: 2367
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exam watch (page 604) Generics constructor