Hello, I am trying to implement a Least Significant Digit Radix Sort using Java. On line 130 I create the array of Linked Lists that will hold the sorted integers and initialize each element to an empty linked List on line 133. Everything works fine except when I want to iterate over this array of linked list to replace the elements in the original input array in lines 162 and 163. Everytime I run this code I get a NoSuchElementException however if I change line 162 from (bucket != null) to (! bucket.isEmpty()) the code works perfect. Isnt checking if the linkedlist header is equal to null the same thing as checking if the linked list is empty?
Error
I am confused why checking if the linked list header is not equal to null gives me an error yet checking if the linked list is empty does not give me an error. Thank you.
>` as it will be much easier to work with. You could even use a stream to set defaults: `List
> foo = Stream.generate(ArrayList::new)` See this example https://www.geeksforgeeks.org/stream-generate-method-java/