Advertisement
Aldin-SXR

removeFromFront()

Mar 5th, 2020
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.29 KB | None | 0 0
  1. /* Remove an item from the beginning of the list */
  2. public void removeFromFront() {
  3.     if (head == null) {                                                     // 1
  4.         throw new IndexOutOfBoundsException("The linked list is empty.");   // 1
  5.     }                                                                       // 1
  6.     head = head.next;                                                       // 2
  7.     size--;                                                                 // 3
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement