The below iterator class return all of the elements except the first, and the last element it returns is null. I’m not sure how to fix it so that it just returns all the elements with no null value in the end.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here
you move to the next element, then return its contents. In effect you always skip the very first element of the list. Do it instead the other way around (using a temporary variable):