33 lines
523 B
Plaintext
33 lines
523 B
Plaintext
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;
|
|
}
|
|
}
|
|
----
|
|
|