You can do the following:
public class Main {
public static void main(String[] args) throws Exception {
String s = convert(new String(), String.class);
}
private static <T>T convert(String string, Class<T> class1) {
return (T) new String();
}
}
EDIT: in your method, the arguments of its not a class of its class and, returning, you must give it a T-return, for example
return (T) mapper.readValue(json, target);
source
share