All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.squid.S1213.html Maven / Gradle / Ivy

There is a newer version: 8.6.0.37351
Show newest version

According to the Java Code Conventions as defined by Oracle, the members of a class or interface declaration should appear in the following order in the source files:

  • Class and instance variables
  • Constructors
  • Methods

Noncompliant Code Example

public class Foo{ 
   private int field = 0;
   public boolean isTrue() {...}     
   public Foo() {...}                         // Noncompliant, constructor defined after methods
   public static final int OPEN = 4;  //Noncompliant, variable defined after constructors and methods
}

Compliant Solution

public class Foo{ 
   public static final int OPEN = 4;
   private int field = 0;
   public Foo() {...}
   public boolean isTrue() {...}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy