What does "variable access definition in wrong order" mean in Checkstyle?

Manoj picture Manoj · Jun 17, 2011 · Viewed 36.7k times · Source

I run checkstyle on my Java code and get this error:

variable access definition in wrong order

Can somebody tell me what that means?

Answer

Sai picture Sai · Jun 17, 2011

Could it be that you have declaration order configured in CheckStyle? Take a look at http://checkstyle.sourceforge.net/config_coding.html#DeclarationOrder

In that link, you will notice that it says ... *According to Code Conventions for the Java Programming Language , the parts of a class or interface declaration should appear in the following order:

Class (static) variables.
First the public class variables,
then the protected,
then package level (no access modifier), and
then the private.

Instance variables.
First the public class variables,
then the protected,
then package level (no access modifier), and
then the private Constructors Methods*