1

How to call the 'test' method below?

static <T> T test(Class<Template<T>> type) {
  // ...
}

static class Template<T> {
  T data;
}

Can't call like this:

test(Template<String>.class);

Please help

Valeamor
  • 53
  • 1
  • 6
  • 1
    What do you mean by "Can't call like this"? What happened when you tried? – Bernie Dec 10 '18 at 05:35
  • 1
    What your test method returns? This code can not compile. – Emre Savcı Dec 10 '18 at 05:35
  • Check the answer of cletus and Santi P. in [Java: how do I get a class literal from a generic type?](https://stackoverflow.com/questions/2390662/java-how-do-i-get-a-class-literal-from-a-generic-type). – samabcde Dec 10 '18 at 05:57

0 Answers0