Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Node addLast(Node head, int newData) {
- Node newNode = new Node(newData);
- if(head == null) {
- head = newNode;
- return head;
- }
- Node temp = head;
- while(temp.next != null) {
- temp = temp.next;
- }
- temp.next = newNode;
- return newNode;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement