我试图变得更加熟悉ArrayList。我想知道如何与tan数组相比,使用Array List进行等效操作。

heap[hole]=heap[child];

heap[hole]=temp;

heap[hole]=heap[hole/2];

最佳答案

ArrayList heapList = new ArrayList(Arrays.asList(heap));
heapList.set(hole, heapList.get(child));

heapList.set(hole, temp);

heapList.set(hole, heapList.get(hole/2);

关于java - 数组与数组列表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20307295/

10-10 02:13