• Post Reply Bookmark Topic Watch Topic
  • New Topic

Invocation of generic method  RSS feed

 
Sam Samson
Ranch Hand
Posts: 63
IntelliJ IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I stumbled on something I don't understand:



getModel() method:


Prefixing method invocation with generic? Can someone explain to me what's happening here?


greez
Sam


 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prefixing method invocation with generic? Can someone explain to me what's happening here?

It's a generic method, see http://docs.oracle.com/javase/tutorial/extra/generics/methods.html
 
Ramesh Pramuditha Rathnayake
Ranch Hand
Posts: 178
2
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you do not tell the the program that T is a genetic when creating the class (Eg: public class MyClass<T>{ ... }), and if you want to use genetics in methods of that class, you have to tell that you are using genetics.

Eg:


In here <T> means not a return type. It means T is used as genetics..

We can invoke method as follows..



And you can do this thing as follows too..


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!