title: Difference between next() and hasNext() in java collections
body: <p>I am new to java and I was going through collections and during the iteration they have used <code>next()</code> and <code>hasNext()</code> methods. What exactly does these two methods do? When do I have to use <code>next()</code> and <code>hasNext()</code>?  </p>