I want to know how to put an array in the Java arrayList.
[] The square brackets are arraylist {} Braces are arrays
[{array 0, array 1, array2} {array 0, array 1, array2}...{array0,array1,array2}]
I want to use it like this.
The array is int num[] = new int[3]. Assuming that the name of the arrayList is numlist, I would appreciate it if you let me know.
java arraylist
Are you talking about this?
public static void main(String[] args){
int[] nums = new int[3];
// arraylist for storing arrays
ArrayList<int[]> mylist = new ArrayList<int[]>();;
mylist.add(nums);
}
When declaring an array list, you can specify the type like ArrayList.
© 2024 OneMinuteCode. All rights reserved.