Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Linked List

 
nomss arra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I need help with my paste method here. Each time it is called, new Node should be created and be inserted to the left of current. Thank You!

http://pastebin.com/DqC0dZ4N

http://pastebin.com/1cw9SQfj
 
Campbell Ritchie
Sheriff
Pie
Posts: 49770
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please copy the offending method here, using the code button. Put the code after the first ] and before the second [.
 
nomss arra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
Campbell Ritchie
Sheriff
Pie
Posts: 49770
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you do is to draw three squares, labelled last temp and previous. Then you put lines between them for each action, or erase the lines, and you find whether you are adding the new node to the right or the left of the original node.
Also, why are you saying "if (current == last)"? That would only add a node at the end of the list, and presumably you want to be able to paste into the middle.
 
nomss arra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I want paste() to paste to the right of current.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49770
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes? And what have you changed in the more recent code?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic