title: How to check if processing the last item in an Iterator?
body: <p>If I have an iterator and I want to check the last value, how can I check it? Like</p>
  
  <pre><code>private Set&lt;String&gt; saarcCountries = new TreeSet&lt;String&gt;();
  Iterator iter = saarcCountries.iterator();
  
  while(iter.hasNext()) {
  
      String name = (String)iter.next();
      int countryId = Integer.parseInt(name);
  
      newsOrAnnouncementInsert.add(newsId);
      newsOrAnnouncementInsert.add(countryId);
      newsOrAnnouncementInsert.add(1);            //addby
  
      if (!(last value in iterator))) {
          newsOrAnnouncementInsert.add("~!~");//Delimiter for Multiple Detail Records
      }//end if
  
  } //end of while
  </code></pre>
  
  <p>How can I check for last value.  what should replace <strong>last value in iterator</strong>?</p>