Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static <T> Node tambahNode_Sebelum(Node<T> front, Node<T> newNode, Node<T> target) {
- Node<T> temp = front;
- Node<T> temp1 = null;
- while (temp != null) {
- if (temp.nodeValue.equals(target.nodeValue)) {
- if (temp1 == null) {
- newNode.next = front;
- front = newNode;
- } else {
- temp1.next = newNode;
- newNode.next = temp;
- }
- return front;
- }
- temp1 = temp;
- temp = temp.next;
- }
- return front;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement