org.sonar.l10n.java.rules.squid.S2156.html Maven / Gradle / Ivy
The newest version!
The difference between private
and protected
visibility is that child classes can see and use protected
members, but they cannot see private
ones. Since a final
class will have no children, marking the members of a final
class protected
is confusingly pointless.
Noncompliant Code Example
public final class MyFinalClass {
protected String name = "Fred"; // Noncompliant
protected void setName(String name) { // Noncompliant
// ...
}
Compliant Solution
public final class MyFinalClass {
private String name = "Fred";
public void setName(String name) {
// ...
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy