Skip to main content

Command Palette

Search for a command to run...

SonarLint: Java - Modifiers should be declared in the correct order (squid:ModifiersOrderCheck)

Published
1 min read
S

I love learning about technology and sharing that with others

The correct order of the modifier in the java is

The Java Language Specification recommends listing modifiers in the following order:

  1. Annotations

  2. public

  3. protected

  4. private

  5. abstract

  6. static

  7. final

  8. transient

  9. volatile

  10. synchronized

  11. native

  12. strictfp

Not following this convention has no technical impact, but will reduce the code's readability because most developers are used to the standard order.

Non-Compliant code

 private final static Collection<String> RELEVANT_SEARCHERS

Compliant Code

  • here we have moved the final after the static according to the conventions
private static final Collection<String> RELEVANT_SEARCHERS
72 views

More from this blog

H

hashcodehub

271 posts

Consistent, Passionate and Organized :)