bethrobson / Head-First-Design-Patterns

Code for Head First Design Patterns book (2020)
3.15k stars 1.92k forks source link

Waitress Class java.util.Iterator Refactor page 336 #33

Open jsudol85 opened 2 years ago

jsudol85 commented 2 years ago

The book mentions on p. 336 that the "private void printMenu (Iterator iterator)" method does not need to be changed. I'm running Eclipse IDE Version: 2022-03 (4.23.0) and the interpreter will complain with a warning that " Iterator is a raw type. References to generic type Iterator should be parameterized", as well as throw an error on the "MenuItem menuItem = iterator.next();" line, stating " Type mismatch: cannot convert from Object to MenuItem".

Changing "private void printMenu (Iterator iterator)" to "private void printMenu (Iterator iterator)" remove both the warning an error and solves the problem