标签:ring style color oid 遍历数组 iter hash remove 遍历
public class Student { String name; int age; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public Student(String name, int age) { super(); this.name = name; this.age = age; } @Override public String toString() { return "Student [name=" + name + ", age=" + age + "]"; } }
import java.util.HashSet; import java.util.Iterator; import java.util.Set; public class StudentTest { public static void main(String[] args) { Set<Student>set=new HashSet<Student>(); set.add(new Student("a", 100)); set.add(new Student("b", 90)); set.add(new Student("c", 80)); set.add(new Student("d", 65)); set.add(new Student("e", 55)); Iterator<Student>ite=set.iterator(); while(ite.hasNext()){ Student s=ite.next(); if(s.age<60){ ite.remove(); } } System.out.println(set); } }
标签:ring style color oid 遍历数组 iter hash remove 遍历
原文地址:http://www.cnblogs.com/zyy1130/p/6820837.html