本文介绍了“class[] arrayname"和“class arrayname[]"之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不明白两者之间的区别
I don't understand the difference between
String[] arrayName = {/*这里有一些数据*/};
和
String arrayName[] = {/*这里有一些数据*/};
在类型之后(String[]
)和数组名称(String arrayName[]
)之后放置方括号有什么区别吗?
如果是,那是什么?
Is there any difference between placing square brackets after the type (String[]
) and after the array name (String arrayName[]
)?
If so, what?
推荐答案
两个声明都会有相同的结果.区别只是风格上的.话虽如此,大多数 Java 风格指南都建议在类型名称上使用方括号,而不是变量名称,即:
Both declarations will have the same result. The difference is only stylistic. Having said that, most Java style guides would recommend having the square brackets on the type name, not the variable name, i.e.:
String[] arrayName = {/*some data here*/};
这篇关于“class[] arrayname"和“class arrayname[]"之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!