All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.squid.S2293.html Maven / Gradle / Ivy

There is a newer version: 8.6.0.37351
Show newest version

Java 7 introduced the diamond operator (<>) to reduce the verbosity of generics code. For instance, instead of having to declare a List's type in both its declaration and its constructor, you can now simplify the constructor declaration with <>, and the compiler will infer the type.

Note that this rule is automatically disabled when the project's java.source.version is lower than 7.

Noncompliant Code Example

List<String> strings = new ArrayList<String>();  // Noncompliant
Map<String,List<Integer>> map = new HashMap<String,List<Integer>>();  // Noncompliant

Compliant Solution

List<String> strings = new ArrayList<>();
Map<String,List<Integer>> map = new HashMap<>();




© 2015 - 2025 Weber Informatics LLC | Privacy Policy