Algorithms and Data Structures

Generic Stack and Queue Implementations 

 Create a new java class called ListNode. Implement ListNode as a generic version ofIntNode.public class ListNode {}
 Create a generic class called Queue, which is a linked list implementation of a queue data type. The queue must have the following methods: 
 public void enqueues (T value){}This method should add a new node to the back of the queue. 
 public T dequeue(){}This method should remove a node from the front of the queue and return its value
  public T peek(){}This method should return the value of the front node without removing it from the queue
 Create a new generic class called Stack, which is a linked list implementation of a stack data type. The stack must have the following methods: 
 public void push(T value){}This method should add a new node to the top of the stack. 
 public T pop(){}This method should remove a node from the top of the stack and return its integer value 
 public T peek(){}This method should return the integer value of the top node without removing it from the stack
 Test your implementation by creating a list of integers and a list of Strings using the generic stack and Queue classes.