以下連結為範例來源出處(若有侵權 懇請告知)
http://pclevin.blogspot.tw/2011/12/java-iterator.html
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class test
{
public static void main(String args[])
{
Set setTest = new HashSet();
Iterator it;
setTest.add("apple");
setTest.add("banana");
setTest.add("tomato");
it = setTest.iterator();
while (it.hasNext())
{
System.out.println(it.next());
}
}
}
沒有留言:
張貼留言