Java 为什么使用LeetCode 138 get错误:找不到符号:变量get?

Java 为什么使用LeetCode 138 get错误:找不到符号:变量get?,java,hashmap,Java,Hashmap,这是我的密码: /** * Definition for singly-linked list with a random pointer. * class RandomListNode { * int label; * RandomListNode next, random; * RandomListNode(int x) { this.label = x; } * }; */ public class Solution { public Ran

这是我的密码:

/**
* Definition for singly-linked list with a random pointer.
* class RandomListNode {
*     int label;
*     RandomListNode next, random;
*     RandomListNode(int x) { this.label = x; }
* };
*/


  public class Solution {
        public RandomListNode copyRandomList(RandomListNode head) {
            //using a map to store the number and Node
            HashMap<RandomListNode,Integer>old_Node=new  HashMap<>(); 
            // using a list to store the Node
            LinkedList<RandomListNode> new_Node = new LinkedList<>(); 
            // store the First_Head
            RandomListNode first_head= head;
    if(head.random!=null){
            int id = old_Node.get[head.random];
            //find the randomNode's number 
            new_Node.get[i].random =new_Node.get[id];

        }
        head=head.next;
        i++;
    }
    return new_Node.get[0];
}
复制随机节点的步骤

  head=first_head;  // change the head so that it can be the first_head
        new_Node.add(null);   //to solve the lastNode[i+1]
         i = 0;
    if(head.random!=null){
            int id = old_Node.get[head.random];
            //find the randomNode's number 
            new_Node.get[i].random =new_Node.get[id];

        }
        head=head.next;
        i++;
    }
    return new_Node.get[0];
}
在这篇文章中,为什么要得到这些东西。。代码无法运行。。 //第33行错误:找不到符号:变量get*

 while(head!=null){
                new_Node.get[i].next=new_Node.get[i+1];
                //Line 33 rror: cannot find symbol: variable get*
    if(head.random!=null){
            int id = old_Node.get[head.random];
            //find the randomNode's number 
            new_Node.get[i].random =new_Node.get[id];

        }
        head=head.next;
        i++;
    }
    return new_Node.get[0];
}
最后的代码

    if(head.random!=null){
            int id = old_Node.get[head.random];
            //find the randomNode's number 
            new_Node.get[i].random =new_Node.get[id];

        }
        head=head.next;
        i++;
    }
    return new_Node.get[0];
}
}

    if(head.random!=null){
            int id = old_Node.get[head.random];
            //find the randomNode's number 
            new_Node.get[i].random =new_Node.get[id];

        }
        head=head.next;
        i++;
    }
    return new_Node.get[0];
}
有人能帮我吗。我认为这段代码不是很好,一定有一些bug

    if(head.random!=null){
            int id = old_Node.get[head.random];
            //find the randomNode's number 
            new_Node.get[i].random =new_Node.get[id];

        }
        head=head.next;
        i++;
    }
    return new_Node.get[0];
}
首先添加地图和列表

    if(head.random!=null){
            int id = old_Node.get[head.random];
            //find the randomNode's number 
            new_Node.get[i].random =new_Node.get[id];

        }
        head=head.next;
        i++;
    }
    return new_Node.get[0];
}
然后将编号和节点放到地图上

    if(head.random!=null){
            int id = old_Node.get[head.random];
            //find the randomNode's number 
            new_Node.get[i].random =new_Node.get[id];

        }
        head=head.next;
        i++;
    }
    return new_Node.get[0];
}

然后新建一个列表来存储节点

您只能对数组使用
[]
。你是说
new\u Node.get(i)
?没有名为
get
的数组,
[]
仅用于数组;我在看API,我会仔细看的,因为我在看。答案使用C,所以在我改变答案后,答案仍然不是真的,请帮助我谢谢
    if(head.random!=null){
            int id = old_Node.get[head.random];
            //find the randomNode's number 
            new_Node.get[i].random =new_Node.get[id];

        }
        head=head.next;
        i++;
    }
    return new_Node.get[0];
}