Java 如何从我的LinkedList创建所有对象值的int[](而不是List<;Integer>;)值?

Java 如何从我的LinkedList创建所有对象值的int[](而不是List<;Integer>;)值?,java,linked-list,integer,array-merge,Java,Linked List,Integer,Array Merge,我有一个合并方法,它以排序的方式合并两个arry。它很好用。 我想创建一个int[]来保存合并方法中的所有值 列表必须是基元int[]; 我试着用 while(singlenode.next!=null){} 但这对我没有帮助 如何将每个单节点值放入int[] 我的代码是从一个简单的LinkedList中获取每个单节点 */ public void merge(SortedList otherSortedList) { // TODO Code hier einfügen Li

我有一个合并方法,它以排序的方式合并两个arry。它很好用。 我想创建一个int[]来保存合并方法中的所有值

列表必须是基元int[]; 我试着用
while(singlenode.next!=null){}
但这对我没有帮助

如何将每个单节点值放入int[]

我的代码是从一个简单的LinkedList中获取每个单节点

 */
public void merge(SortedList otherSortedList) {
    // TODO Code hier einfügen
    ListNode singlenode = new ListNode(0);
    ListNode currentNode = singlenode;

    ListNode mainListhead = this.headNode;
    ListNode otherListHead = otherSortedList.headNode;
    int[] listInteger = new int[otherSortedList.getLength() * 2];
    int count = 0;

    while (mainListhead != null && otherListHead != null) {

        if (mainListhead.value < otherListHead.value) {
            currentNode.next = mainListhead;
            mainListhead = mainListhead.next;

        } else {
            currentNode.next = otherListHead;
            otherListHead = otherListHead.next;

        }
        currentNode = currentNode.next;
    }

    if (mainListhead != null) {
        currentNode.next = mainListhead;
        mainListhead = mainListhead.next;
        count++;

    }

    if (otherListHead != null) {
        currentNode.next = otherListHead;
        otherListHead = otherListHead.next;
        count++;

    }
*/
公共作废合并(SortedList其他SortedList){
//待办事项代码hier einfügen
ListNode singlenode=新ListNode(0);
ListNode currentNode=singlenode;
ListNode mainListhead=this.headNode;
ListNode otherListHead=otherSortedList.headNode;
int[]listInteger=new int[otherSortedList.getLength()*2];
整数计数=0;
while(mainListhead!=null&&otherListHead!=null){
if(mainListhead.value

}

据我所知,您必须创建一个整数[]并将值转储到其中(元素可以为null,这可能是您试图避免的?),或者运行for循环并将每个值取消装箱到int[]。