Question: JAVA I need an expert to edit on the code to make it works on online compiler and solve what inside the main in the

JAVA

I need an expert to edit on the code to make it works on online compiler and solve what inside the main in the comment:

interface MyQueue { public void enqueue(T element);

public T dequeue();

public T first(); public boolean isEmpty(); public int size();

public String toString();

} class MyLinkedListQueue implements MyQueue { MyLinkedList list = new MyLinkedList(); public void enqueue(T element) { list.addLast(new Node(element)); } public T dequeue() { if (isEmpty()) throw new QueueEmptyException("Queue is empty"); // remove element from the front of the list Node o = list.removeFirst(); return o.getElement(); }

public T first() { if (isEmpty()) return null; return list.first().getElement(); } public boolean isEmpty() { if (list.size()==0) return true; return false; }

public int size() { return list.size(); }

public String toString() { return "Queue"; }

} public class Main { public static void main(String[] args) { MyQueue queue = new MyLinkedListQueue();

queue.enqueue(34); queue.enqueue(56); queue.enqueue(12); queue.enqueue(8); queue.enqueue(44); queue.enqueue(12); queue.enqueue(45);

// a) Now dequeue the queue 3 times // b) Now insert 72 in the queue

//show the whole queue }

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!