• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing arguments to method with parmeter as Class<T>

 
Rohit Shaarma
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I need to call this below method




but i am not getting how to pass argument for Class<T> parameter, any help is greatly appreciated.



-Regards,
Rohit Sharma
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a class literal. For instance, if T is String, you can pass in String.class as the argument.
 
Rohit Shaarma
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Matthew for the reply.
I tried doing that but whatever type of of class literal i pass every time it shows on of these compilation errors.

The method executeQuery(String, Class<T>, Parameter...) in the type FacebookClient is not applicable for the arguments (String,
Class<String>, String)

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15480
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That error message is because of the third (and later) argument(s), not the second argument.

The third argument must be of type Parameter. You are trying to pass a String instead.
 
Rohit Shaarma
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Jasper i just figured out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic