import java.util.*;
public class Test{
public static void main(String[] args) {
Collection c = new HashSet();
c.add(new Name("F11", "l11"));
c.add(new Name("F2", "l2"));
c.add(new Name("F31", "l31"));
for(Iterator i=c.iterator(); i.hasNext();){
Name n = (Name)i.next();
if(n.getFirstName().length()<3){
n.remove();
}
}
System.out.println(c); }
}
class Name {
String firstName, lastName;
public Name(String firstName, String lastName) {
this.firstName = firstName; this.lastName = lastName;
}
public String getFirstName() {return firstName;}
}
public class Test{
public static void main(String[] args) {
Collection c = new HashSet();
c.add(new Name("F11", "l11"));
c.add(new Name("F2", "l2"));
c.add(new Name("F31", "l31"));
for(Iterator i=c.iterator(); i.hasNext();){
Name n = (Name)i.next();
if(n.getFirstName().length()<3){
n.remove();
}
}
System.out.println(c); }
}
class Name {
String firstName, lastName;
public Name(String firstName, String lastName) {
this.firstName = firstName; this.lastName = lastName;
}
public String getFirstName() {return firstName;}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货