I want to change the return type of this method to a class (ReturnContainer) that can hold the tupelo object in addition to another return value that I need to send back to the calling method.
I’ve never worked with this <T> concept in Java before so I don’t how to reconfigure this method to work the way I need it to.
public static <T extends LocationCapable> List<T> test(Class<T> incomingClass)
{
List<TestTuple<T>> tupelo = new ArrayList<TestTuple<T>>();
return tupelo;
}
When I try to change the code to the listing below, I get the error:
T cannot be resolved to a type
How can I have a return type of ReturnContainer but still allow the incomingClass to be a dynamic type?
public static ReturnContainer test(Class<T> incomingClass)
{
List<TestTuple<T>> tupelo = new ArrayList<TestTuple<T>>();
ReturnContainer rc = new ReturnContainer(tupelo, incomingClass);
return rc;
}
You’re missing the type parameter:
To my eyes, though, this looks weird. Shouldn’t
ReturnContainerhave a type parameter, too? In which case, you’d have