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

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

There is a newer version: 8.6.0.37351
Show newest version

Classes with only private constructors should be marked final to prevent any mistaken extension attempts.

Noncompliant Code Example

public class PrivateConstructorClass {  // Noncompliant
  private PrivateConstructorClass() {
    // ...
  }

  public static int magic(){
    return 42;
  }
}

Compliant Solution

public final class PrivateConstructorClass {  // Compliant
  private PrivateConstructorClass() {
    // ...
  }

  public static int magic(){
    return 42;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy