I'm Confused with specifically calling Generic Method. If we call generic method like JenericMethod.<String>ship(argument1), it is suppose to call the method that its parameter is array. However in this case, it is calling the overloaded function that doesn't have Array as a parameter. What am I missing here?
Rob Spoor wrote:Campbell is right. Both of your methods have a generic argument T.
One of the method has T and the other T as argument/parameter.
Rob Spoor wrote:When you use JenericMethod.<String>ship, you use String for T, not for T - because the generic type is not T but T.
I don't think it is possible to declare generic type as T, And JenericMethod.<String>ship calls the overloaded array method while the generic type is T. The confusing thing for me is that when I use JenericMethod.<String>ship to call the method, the compiler identifies correctly which method to call based on the argument.
As you can see in the image below, the IDE also identifies the correct/ my assumption/ method using the argument type.