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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -