Posts

CollectionFramework-Part-2 In Java

Iterators in Java Iterator is used to iterator over collection of objects. Iterator is interface. package  Test; import  java.util.ArrayList; import  java.util.Iterator; public   class  Example2 {                    /**      * Returns { true} if the iteration has more elements.      * (In other words, returns {true} if  {next}  would      * return an element rather than throwing an exception.)      *      *  @return  {@code true} if the iteration has more elements      */              public   static   void  main(String[]  args ) {                         ArrayList<Integer>  array  =  new  ArrayList<Integer>();                          array .add(3);                          array .add(4);                          array .add(5);                                                 Iterator<Integer>  itr  =  array .iterator();                          while ( itr .hasNext()){                                     S