=== duplicates: S1171

=== on 14 Dec 2015, 10:46:39 Nicolas Peru wrote:
\[~ann.campbell.2] The rule examples do not match the title and descritption : 


a static initiliazer has the following form : 


----
static {
   //some code
}
----

if you use this on an instance variable, code does not compile. 


However the other way around will compile and is probably a mistake (using a non static initializer on a static variable) : 


----
class A {
public static List<String> foo = new ArrayList<>();

{
  foo.add("foo");
}
}
----

As this code will be executed for every instanciation of A. 




=== on 14 Dec 2015, 20:00:17 Ann Campbell wrote:
Thanks [~nicolas.peru]. Look now.

=== on 15 Dec 2015, 14:10:41 Nicolas Peru wrote:
LGTM. Moving issue to java top as this is easy to achieve.

