Type inference is a Java compiler's ability to look at each method invocation and corresponding declaration to determine the type argument (or arguments) that make the invocation applicable. The inference algorithm determines the types of the arguments and, if available, the type that the result is being assigned, or returned. Finally, the inference algorithm tries to find the most specific type that works with all of the arguments.
To illustrate this last point, in the following example, inference determines that the second argument being passed to the pick method is of type Serializable:
Here in the part in bold, is the document trying to say that new ArrayList<String>() is of type serializable? I understand that the return type is of type serializable. But how can new ArrayList<String>() be of type Serializable?
At a more general level, a class IS-A its class type, its super class types, and all the interfaces it (and its super classes) implements. To test this, you can simply use the instanceof operator -- and you will see that it returns true.
Stephan van Hulst wrote:ArrayList implements Serializable. String implements Serializable. The return type is Serializable. Serializable is the most specific type that all arguments and returned value have in common.
String doesn't even matter here, it's only the ArrayList part that needs to be Serializable. The following still compiles, even though Object doesn't implement Serializable: