public class Fu {
private String collection;
private String stretch;
public Fu(String collection, String stretch) {
this.collection = collection;
this.stretch = stretch;
}
public String getCollection() {
return collection;
}
public String getStretch() {
return stretch;
}
}
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class Le{
public static void main(String[] args) {
Map<String,String> empty=new HashMap<>();
Fu a1=new Fu("muj", "yans");
Fu a2=new Fu("shouc","danx");
Fu a3=new Fu("kx","pk");
empty.put(a1.getCollection(),a1.getStretch());
empty.put(a2.getCollection(),a2.getStretch());
empty.put(a3.getCollection(),a3.getStretch());
Set<String> border=empty.keySet();
Iterator<String> grid=border.iterator();
//while执行了两次。
while (grid.hasNext()) {
System.out.print(grid.next()+" ");
System.out.print(empty.get(grid.next())+" ");
//迭代了四次,超过三次。
}
}
}
private String collection;
private String stretch;
public Fu(String collection, String stretch) {
this.collection = collection;
this.stretch = stretch;
}
public String getCollection() {
return collection;
}
public String getStretch() {
return stretch;
}
}
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class Le{
public static void main(String[] args) {
Map<String,String> empty=new HashMap<>();
Fu a1=new Fu("muj", "yans");
Fu a2=new Fu("shouc","danx");
Fu a3=new Fu("kx","pk");
empty.put(a1.getCollection(),a1.getStretch());
empty.put(a2.getCollection(),a2.getStretch());
empty.put(a3.getCollection(),a3.getStretch());
Set<String> border=empty.keySet();
Iterator<String> grid=border.iterator();
//while执行了两次。
while (grid.hasNext()) {
System.out.print(grid.next()+" ");
System.out.print(empty.get(grid.next())+" ");
//迭代了四次,超过三次。
}
}
}