Java examples for java.util:Iterator
Iterator iterates Equal Sequence
//package com.book2s; import java.util.*; public class Main { public static void main(String[] argv) { Iterator iter1 = java.util.Arrays.asList("asdf", "book2s.com") .iterator();/* w w w. ja v a2 s.c o m*/ Iterator iter2 = java.util.Arrays.asList("asdf", "book2s.com") .iterator(); System.out.println(iteratesEqualSequence(iter1, iter2)); } public static boolean iteratesEqualSequence(Iterator<?> iter1, Iterator<?> iter2) { while (iter1.hasNext()) { if (!iter2.hasNext()) return false; Object o1 = iter1.next(); Object o2 = iter2.next(); if (!o1.equals(o2)) return false; } if (iter2.hasNext()) return false; return true; } }