File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing arguments to method with parmeter as Class<T>

 
Rohit Shaarma
Greenhorn
Posts: 11
  • 0
  • 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: 4549
8
Java Netbeans IDE Scala
  • 0
  • 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
  • 0
  • 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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Jasper i just figured out.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic