As already stated, getTest
returns a raw type. The correct implementation of the method will look like this:
public static <T> Test<T> getTest() { return new Test<>(); }
Please note that you need to specify a common parameter for static methods - this can be anything, since it is not the same T
as in the class signature (but it is usually customary to use the same name if it is used in the same place )
Then it depends on whether the compiler can infer the correct type, sometimes it may need your "help", for example
List<String> tester = Test.<String>getTest().getTestIntegers();
(I have not tried if necessary there, but how it looks)
source share