1 Reply Latest reply: Jul 30, 2007 3:21 PM by 807605 RSS

    adding node to the linkedlist

    807605
      How do I add a node to the beginning of the list. Here's what I have done so far (I'm new to java).. help!

      class Node {
           public int value;
           public Node next;
      }

      class LinkedList {
      private int idx=0;
           private Node first;
      Node data[]= new Node[10];

           public void addNodeToBeginningOfList( Node node) {
      node.next = first;
      data[idx]=node;
      idx++;
           }
      }