Classs AAA
int i;
T T;
}
And there is a User class
The class User {
String name;
}
Methods
The public & lt; T> T Fun (Class
Return the t1;
}
Now want to ask how the parameters AAA
call like this: class1 & lt; User> C=Fun (AAA
Want to ask, how should call,,,
CodePudding user response:
Who knew that raise a point ah,CodePudding user response:
You the Fun is the wrong way you write go in and see you return in the compiler is a Java. Lang, Class and all that is needed is a normal Class, so you this method is wrong the compiler complainsCodePudding user response:
Brother, you ask the question, accurate description: multilayer nested class how to obtain a generic class?Error:
1, AAA
2, the new AAA
The above two kinds of not sure, the first compilation is not through, the second external class resolution through, internal class will be resolved as a map
Common solutions: with the help of the fastJson TypeReference
The results first converted to a String, use String directly. The class
Then
AAA
}. GetType ());
Done!
Prerequisites: the result is the json format to convert multilayer nested generic class