java - If the address of the node is stored in the hashmap(index), how can i get the address so that i can use it as a node again? -
hashmap newmap = new hashmap(); public void add(int v1,int v2) { node newnode = new node(); newnode.data = v2; newnode.next = head; head = newnode; newmap.put(v1,head); system.out.println("head1 " + head); }// storing address of node in index storing value of v2 in node.next i can address of node cant traverse nodes because says object cannot node. ex.
system.out.println("head " + newmap.get(v[v2])); // can address node n; node n; int cnt = 0; for(n = newmap.get(v[v2]); n!=null; n=n.next) // error here { system.out.print("|" + n.data + "| |-> "); v2++; }
Comments
Post a Comment