Can someone explain the code below? Is .next an operator in java that pushes the pointer to the next node in the linked list?
Node E < -- type node?

public E dequeue ( ) throws EmptyQueueException {
 if (isEmpty ( )) {
 throw new EmptyQueueException (”Queue under flow”) ;
 else{
 if (end==front.next) // Special case , dequeue single element in queue
 end = front;
 E val = front.next.element;
 front.next = front.next.next; / / Bypass first node
 return(val);
 }
 }

`

Recommended Answers

All 3 Replies

Next isn't likely an operator or method. I believe its just a member variable with a reference to the next Element

SKy is right,next is not a method or operator,it is just a member variable.Can you provide the complete code so as more information can be provided on it's working...

i'll paste the code shortly, but if you say it is a variable which contain references to the next node in the list.

How does it get populated? its kind of confusing as to how the code works, I know how Linked lists work in general,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.