Synopsis: | Use the diamond operator to let the type be inferred automatically |
Language: | Java |
Severity Level: | 6 |
Category: | TypeResolution |
Description: |
Use the diamond operator to let the type be inferred automatically. With the Diamond operator it is possible to avoid duplication of the type parameters. Instead, the compiler is now able to infer the parameter types for constructor calls, which makes the code also more readable.List<String> strings = new ArrayList<String>(); // unnecessary duplication of type parameters |