Java Coding standard: multiple variable declaration

94 views Asked by At

Which of the following is best practice according to Java coding standards

public void function1(){
    int i1 = 0, i2 = 1, i3 = 2;
    // some code here
}

public void function1(){
    int i1 = 0;
    int i2 = 1;
    int i3 = 2;
    // some code here
}

Is there any practice which recommends the usage of first approach, for me its not good for readability but for others in my team it is good practice.

1

There are 1 answers

3
gaborsch On BEST ANSWER

Java does not regulate this, it's really a habit, depends on you and your team. I personally believe that 95% of he teams does not prefer this one-line declaration, it's not readable.