So my current code looks like this. The idea is to take in an instance of different classes using generic type T and return those instances.
I should be able to call instances of classes like this
new A().add(new B())
public static <T> T <T> add(T t) {
return new T();
}
Basically to me the return type should be the class itself so that it can take a new instance through the return type.
Can someone guide me as to where my logic is going wrong?