aspose file tools*
The moose likes Java in General and the fly likes Passing arguments to method with parmeter as Class<T> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Passing arguments to method with parmeter as Class<T>" Watch "Passing arguments to method with parmeter as Class<T>" New topic
Author

Passing arguments to method with parmeter as Class<T>

Rohit Shaarma
Greenhorn

Joined: Nov 16, 2011
Posts: 11
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

Joined: Apr 06, 2010
Posts: 4422
    
    8

You can use a class literal. For instance, if T is String, you can pass in String.class as the argument.
Rohit Shaarma
Greenhorn

Joined: Nov 16, 2011
Posts: 11
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

Joined: Aug 16, 2005
Posts: 14274
    
  21

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Rohit Shaarma
Greenhorn

Joined: Nov 16, 2011
Posts: 11
Thanks a lot Jasper i just figured out.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Passing arguments to method with parmeter as Class<T>