Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Passing arguments to method with parmeter as Class<T>
Rohit Shaarma
Greenhorn
Posts: 11
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All,
I need to call this below method
<T> List<T> executeQuery(String query, Class<T> objectType, Parameter... parameters){ }
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
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 16084
88
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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.
Jesper's Blog
-
Pluralsight Author Page
Rohit Shaarma
Greenhorn
Posts: 11
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks a lot Jasper i just figured out.
The airline is called "Virgin"? Don't you want a plane to go all the way? This tiny ad will go all the way:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Generic method declaration
T cannot be resolved to a type
Generic method question
build function that return different types based on param
passed SCJp1.5 with 95%. | earlier topic static class - nested class : are they same?
More...