I want to put int[] in the List <Integer>, how do I do it?

Asked 2 years ago, Updated 2 years ago, 88 views

I want to put int[] in the list, how do I do it?

collections java array boxing autoboxing

2022-09-22 22:17

1 Answers

int[] ints = {1, 2, 3};
    List<Integer> intList = new ArrayList<Integer>();
    for (int index = 0; index < ints.length; index++)
    {
        intList.add(ints[index]);
    }

You can do it like this.


2022-09-22 22:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.