How a java iterator works internally?

Viewed 10024

/* I have a list of employees */

List<Employee> empList=new ArrayList<Employee>();
empList.add(employee1);
empList.add(employee2);
empList.add(employee3);
empList.add(employee4);

/* I have taken an iterator */

Iterator<Employee> empIterator=empList.iterator();

In the above line , I was trying to get an iterator over the list. My doubt is what would be there in the iterator (will all the list objects be copied into it or the list object is cloned or... I'm just clueless). Help me in understanding this. Thanks in advance.

2 Answers
Related