Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

variable access definition in wrong order

Can somebody tell me what that means?

like image 311
Manoj Avatar asked Jun 17 '11 20:06

Manoj


2 Answers

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*

like image 180
Sai Avatar answered Oct 24 '22 08:10

Sai


Maybe it is a little late for answering this question (:D) but in my case i had some thing like that:

 public final class ClassA{
    private ClassA() {
    }
    private static Logger LOG = LoggerFactory.getLogger(ClassA.class);

and after i changed the order to:

public final class ClassA{
        private static Logger LOG = LoggerFactory.getLogger(ClassA.class);
 private ClassA() {
            }

my problem solved.

like image 2
Saman Salehi Avatar answered Oct 24 '22 07:10

Saman Salehi