简体   繁体   English

在Java中声明包含Arraylist的Arraylist的语法

[英]Syntax to declare an Arraylist containg an Arraylist in java

I have a class which I called Hour , and I declared an Arraylist <day> , which contains 24 elements of Hour class. 我有一个称为Hour的类,并且声明了一个Arraylist <day> ,其中包含Hour类的24个元素。

Now, I would like to declare an Arraylist of Arraylist<day> but I am not sure about the syntax for that. 现在,我想声明一个Arraylist Arraylist<day>的Arraylist,但是我不确定其语法。

ArrayList <Hour> day  = new ArrayList <Hour> (); //// just for test now 
ArrayList <day> test  = new ArrayList <day> ();     

the problem is in this line 问题在这条线

ArrayList <day> test  = new ArrayList <day> ();     

正确的语法是

     List<ArrayList<Hour>> = new ArrayList<ArrayList<Hour>>();     

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

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