include::../why-fields.adoc[]

=== Noncompliant code example

[source,java]
----
class Foo {
  public int myField;

  public void doSomething() {
    int myField = 0; // Noncompliant
    // ...
  }
}
----

== Resources

=== Documentation

* CERT - https://wiki.sei.cmu.edu/confluence/display/java/DCL51-J.+Do+not+shadow+or+obscure+identifiers+in+subscopes[DCL51-J. Do not shadow or obscure identifiers in subscopes]

=== Related rules

* S2176 - Class names should not shadow interfaces or superclasses
* S2387 - Child class fields should not shadow parent class fields
* S4977 - Type parameters should not shadow other type parameters

include::../rspecator.adoc[]
