In java implement the following methods as indicated within thecode of stacklist.java
public class Node{
int data;
Node next;
public Node(int data){
this.data = data;
next = null;
}
}
import java.util.Scanner;
public class LinkedListBasic {
Node head;
Node tail;
// inserts data to the end of the list only using the headpointer
public void append(int data){
if(head == null){
Node newNode = new Node(data);
head = newNode;
} else {
Node newNode = new Node(data);
Node currentNode = head;
while(currentNode.next != null){
currentNode = currentNode.next;
}
currentNode.next = newNode;
}
}
// inserts data to the beginning of the list
public void prepend(int data){
if(head == null){
Node newNode = new Node(data);
head = newNode;
return;
}
Node newNode = new Node(data);
newNode.next = head;
head = newNode;
}
// insert a new data after the given
PayPal Gateway not configured
PayPal Gateway not configured