I’m looking through EntityManager.java and I see
public <T extends Object> T find(Class<T> type, Object o, LockModeType lmt, Map<String, Object> map);
I’ve never seen <X> type declarations within a class method definition. What does this mean?
public <T extends Object> T find( seems like it’s defining that T will extend another class. Am I understanding that this requires you to extend another object?
This means that you define a generic function, which has a type parameter denoted by T for the sake of definition. T has to be a subclass (extends) of Number. The function returns an object of type T.
Then you can call the function like that:
but you the following is a compile time error:
because String doesn’t extend Number.