This week's book giveaways are in the Refactoring and Agile forums. We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line! See this thread and this one for details.
Towards void-return-type generic method why we use preceding <T>, before return type. What does it denotes? Please clarify. I referred K&B however it is not clear to me. For example:
Thank you in advance!
posted 7 years ago
It signals to the compiler that your method is in fact a generic method. Otherwise T would not be recognised as a type, but a class name. If you wrote this for example:then the compiler expects that T is a class type for the parameter, not a generic type to be substituted. You'll probably get compiler errors about the class not being found (unless you happen to have a class called T lying around!).
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )