# Reorder Modifiers

# Description

This rule reorders the modifiers on Type, Field and Method Declarations in the following priority:

  • public
  • protected
  • private
  • abstract
  • default
  • static
  • final
  • transient
  • volatile
  • synchronized
  • native
  • strictfp

# Benefits

Improves the readability by unifying the order of modifiers in Type, Field and Method declarations.

# Tags

# Code Changes

# Field Declarations

Pre

final static public String FINAL_STATIC_PUBLIC = "";  
static final public String STATIC_FINAL_PUBLIC = "";  
final public static String FINAL_PUBLIC_STATIC = "";  
public final static String PUBLIC_FINAL_STATIC = "";  
static public final String STATIC_PUBLIC_FINAL = "";  
public static final String PUBLIC_STATIC_FINAL = "";  

Post

public static final String FINAL_STATIC_PUBLIC = "";
public static final String STATIC_FINAL_PUBLIC = "";
public static final String FINAL_PUBLIC_STATIC = "";
public static final String PUBLIC_FINAL_STATIC = "";
public static final String STATIC_PUBLIC_FINAL = "";
public static final String PUBLIC_STATIC_FINAL = "";

# Methods Declaration

Pre

static synchronized protected final void staticMethod() {
    ...
}

Post

protected static final synchronized void staticMethod() {
    ...
}

# Type Declaration

Pre

static private class PrivateStaticClass {
    ...
} 

Post

private static class PrivateStaticClass {
    ...
} 

🛠️ Auto-refactor Available

You can auto-refactor this with jSparrow.
Drop this button to your Eclipse IDE workspace to install jSparrow for free:

Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client

Need help? Check out our installation guide.

# Properties

Property Value
Rule ID ReorderModifiers
First seen in jSparrow version 3.6.0
Minimum Java version 1.1
Remediation cost 2 min
Links