Question: why is my code not moving to the next item in the list?public ItemType getNextItem(){ // check if the list is empty if(currentPos == null

why is my code not moving to the next item in the list?public ItemType getNextItem(){ // check if the list is empty if(currentPos == null && head != null) { // System.out.println("hello you previously did r"); currentPos = head; //currentPos = currentPos.next; return head.info; }//if if(head == null) { System.out.println("List is empty"); return null; // check if we are at the end of the list }//if if(currentPos.next == null) { System.out.println("The end of the list has been reached"); return null; }//if // general case System.out.println("hello this is a general case"); currentPos = currentPos.next; //return currentPos.info; //} // else //currentPos = currentPos.next; System.out.println("you made it to the end of the method"); return currentPos.info; } // getNextItem

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 Programming Questions!