Implement a peek using a existing iterator next and hasnext function. Interviewer was interested in correct syntax.
Anonymous
simple boolean and temp variable to hold the front element. Boolean value to check whether element is set or not (peek has been invoked or not). It can also be implemented without boolean with just temp variable then we need to check for null ness instead of boolean value.
Check out your Company Bowl for anonymous work chats.