比对应该是从第一个开始的,为什么结果没有按顺序输出?该怎么改?
package thirdJava;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
class student{
private String num ;
private String name ;
private int cl ;
public student(String num, String name, int cl) {
super();
this.num = num;
this.name = name;
this.cl = cl;
}
public String getNum() {
return num;
}
public String getName() {
return name;
}
public int getCl() {
return cl;
}
}
public class oj2142 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in) ;
int n = sc.nextInt() ;
Map<student,String> map = new HashMap<student,String>() ;
for(int i=0; i<n; i++){
map.put(new student(sc.next(),sc.next(),sc.nextInt()), sc.next()) ;
}
Set<Entry<student,String>> en = map.entrySet() ;
int m = sc.nextInt() ;
Map<String,String> map2 = new HashMap<String,String>() ;
for(int j=0; j<m; j++){
map2.put(sc.next(), sc.next()) ;
}
Set<Entry<String,String>> sets = map2.entrySet() ;
for(Entry<student,String> x : en){
for(Entry<String,String> y : sets){
if(x.getValue().equals(y.getKey())){
System.out.println(x.getKey().getNum() + " " + y.getValue());
}
}
}
}
}