简体   繁体   中英

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.

Now, I would like to declare an Arraylist of Arraylist<day> but I am not sure about the syntax for that.

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>>();     

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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