简体   繁体   English

float的arraylist的arraylist的Java初始值

[英]Java initial value of arraylist of arraylist of float

Given the below code 给出以下代码

ArrayList<ArrayList<Float>> fWordTagProb = new ArrayList<ArrayList<Float>>();
for(int f=0;f<pennTreeTags.size();f++)
    fWordTagProb.add(new ArrayList<Float>());

What is the initial value of each "cell" in this 2d array? 此二维数组中每个“单元”的初始值是多少? Is it zero? 是零吗?

Hence is it the same for type Integer? 因此,对于Integer类型是否相同?

Thanks in advance for the help 先谢谢您的帮助

Each element of fWordTagProb is an empty ArrayList . fWordTagProb每个元素都是一个空的ArrayList Logically there are nothing yet in the empty lists. 逻辑上说,空列表中什么都没有。

It would be same if you used Integer instead of Float . 如果使用Integer而不是Float ,则将是相同的。

The cells are boxed Floats, and so are reference types. 单元格是框状的Floats,引用类型也是如此。 The default value of a reference type is null , and so too is the default value of each cell. 引用类型的默认值为null ,每个单元格的默认值也是如此。

I should add that the sub-ArrayLists are empty, and so there aren't actually any cells at all. 我应该补充一点,子ArrayLists为空,因此实际上根本没有任何单元格。 Should the sub-lists be initialized to the desired size, then the cells will indeed be null . 如果将子列表初始化为所需的大小,则单元格确实将为null

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM