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

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

There is a newer version: 8.6.0.37351
Show newest version

Method/constructor references are more compact and readable than using lambdas, and are therefore preferred.

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

Noncompliant Code Example

  List list = new ArrayList();
  list.add(0);
  list.add(1);
  list.add(2);

    list.forEach(n -> { System.out.println(n); });

Compliant Solution

  List list = new ArrayList();
  list.add(0);
  list.add(1);
  list.add(2);

  list.forEach(System.out::println);




© 2015 - 2025 Weber Informatics LLC | Privacy Policy