Normal
Wie wäre es mit so einer Lösung:[CODE]public class Generic<T> { public static void main(String[] args) { String str = "hello"; Generic<String> g = new Generic<>(String.class); g.doStuff(str); } private Class<T> type; public Generic(Class<T> type) { this.type = type; } private void doStuff(T arg) { System.out.println(arg); }}[/CODE]
Wie wäre es mit so einer Lösung:
[CODE]public class Generic<T> {
public static void main(String[] args) {
String str = "hello";
Generic<String> g = new Generic<>(String.class);
g.doStuff(str);
}
private Class<T> type;
public Generic(Class<T> type) {
this.type = type;
private void doStuff(T arg) {
System.out.println(arg);
}[/CODE]