What is difference between Iterator and for loop
Answer Posted / amit r
There are basic 3 differences between For and Iterater.
1.
Using Iterater we can check if the object exists or not by using hasNext method. Where as in For Loop, there is not such method. Therefore, For Loop will be executed at fixed amount at every time.
2.
Using Iterator we can add or remove objects from the underlying collection. In For Loop, if we do so, concurrent modification exception will be thrown.
3.
Using Iterator we can move forward or backward where as For Loop can't.
:)
| Is This Answer Correct ? | 7 Yes | 6 No |
Post New Answer View All Answers
Is it possible to override the main method?
What are the methods to rectify ambiguities in the interfaces in JAVA?
What is arrays sort in java?
What are the main differences between the java platform and other platforms?
Explain the difference between private, public, package and protected in java?
What are the types of java languages?
What is entry in java?
List two java ide’s?
What is the purpose of object oriented programming?
What is a Null object?
What is public static void main?
which is advanced deep technology in java launched by the sun microsystem??? The answer is very logical If u need correct answer mail me at priya_gupta@gmail.com
What is bitwise complement?
What is an inner class in java?
Which command from the jdk compiles a java program?