이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.

Metadata

ID: java-best-practices/one-declaration-per-line

Language: Java

Severity: Notice

Category: Best Practices

Description

In Java, it is possible to declare multiple variables of the same type on a single line using commas. This can make code more cluttered and less readable. Declare each variable on a separate line to improve code clarity and maintainability.

Non-Compliant Code Examples

public class Person {
    // combined declarations (same line) - a violation
    String firstName, lastName;

    // combined declaration (diff line) - no violation
    String firstName,
        lastName;
}

Compliant Code Examples

public class Person {
    // separate declarations - no violation
    String firstName;
    String lastName;     
}
PREVIEWING: dgreen15/github-error-fix