Java编码标准:多变量声明 [英] Java Coding standard: multiple variable declaration

查看:101
本文介绍了Java编码标准:多变量声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是根据Java编码标准的最佳实践

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.

推荐答案

Java确实不规范这一点,这确实是一个习惯,取决于您和您的团队。我个人认为他的团队中有95%的人不喜欢这种单行声明,因为它不可读。

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.

这篇关于Java编码标准:多变量声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆