Skip to main content

Command Palette

Search for a command to run...

SonarLint: Java- Multiple variables should not be declared on the same line

Published
1 min read
S

I love learning about technology and sharing that with others

Declaring multiple variables on one line is difficult to read.

Noncompliant Code Example

class MyClass {

  private int a, b;

  public void method(){
    int c; int d;
  }
}

Compliant Solution

class MyClass {

  private int a;
  private int b;

  public void method(){
    int c;
    int d;
  }
5 views

More from this blog

H

hashcodehub

271 posts

Consistent, Passionate and Organized :)