As Iterator is an interface with hasNext(), next() and remove() methods. But where is the implementation for all these methods in Java classes?
As Iterator is an interface with hasNext(), next() and remove() methods. But where is
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.
Almost every concrete collection has its own implementation, optimized for that specific collection. You don’t have to bother about the details. But here are some examples:
LinkedList–class ListItr implements ListIterator<E>ArrayList–class ListItr extends Itr implements ListIterator<E>HashSet– actually backed byHashMap.keySet()Becasue
Iteratoris an interface, you can do fancy things with it, like wrapping and decorating it, without paying attention to the actual implementation.