To create an array list in Java, you declare an ArrayList variable and call the ArrayList constructor to instantiate an ArrayList object and assign it to the variable: ArrayList friends = new ArrayList(); You can optionally specific a capacity in the ArrayList constructor: ArrayList friends = new ArrayList(100);
How do I make a list in an array?
To create an array list in Java, you declare an ArrayList variable and call the ArrayList constructor to instantiate an ArrayList object and assign it to the variable: ArrayList friends = new ArrayList(); You can optionally specific a capacity in the ArrayList constructor: ArrayList friends = new ArrayList(100);
Can you put a list in an array?
It is possible. However, it’s not possible to have a list containing multiple types. The hack is to create all Object arrays and store your values, but if you need this kind of hack you should probably rethink about your approach.