差异数组初始化 [英] Difference in Array initialization

查看:140
本文介绍了差异数组初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然找了一个源文件,我看到了数组初始化的方法有两种。我不知道是否有

While looking over a source file, i saw two ways of array initialization. I wonder is there a difference between

int[] value = new int[0];

int[] value_next = new int[]{};

推荐答案

其实没有什么区别。这是 语法糖 在Java数组声明。

Actually there is no difference. It's Syntactic sugar in java array declaration.

第一种类型的声明是减少混乱,至少对我来说。)

The first type declaration is less confusing, at least for me :).

注意:我不知道你为什么给定长度的宣布时

Note: I'm not sure why you given the length as zero while declaring.

如果可能的话,要经过 http://stackoverflow.com/a/19558179/1927832 超过另一些优势

If possible, go through http://stackoverflow.com/a/19558179/1927832 for some advantages over another.

这篇关于差异数组初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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