class Student{
private String name;
private int age;
Student(String name,int age){
this.name=name;
this.age=age;
}
public String toStrint(){
return name+":::"+age;
}
}
class xuexiao{
public void xuexiao1(){
TreeMap<String,ArrayList<Student>> xuexiao=new TreeMap<String,ArrayList<Student>>();
ArrayList<Student> yiban=new ArrayList<Student>();
ArrayList<Student> erban=new ArrayList<Student>();
xuexiao.put("yiban",yiban);
xuexiao.put("erban",erban);
yiban.add(new Student("zhangsan",12));
yiban.add(new Student("zhangsan",13));
yiban.add(new Student("zhangsan",14));
erban.add(new Student("wangwu",23));
erban.add(new Student("wangwu",24));
erban.add(new Student("wangwu",22));
}
public void getStudent(TreeMap<String,ArrayList<Student>> xuexiao,ArrayList<Student> banji){
Iterator<String> it=xuexiao.keySet().iterator();
while(it.hasNext()){
String s=it.next();
ArrayList<Student> ss=xuexiao.get(s);
if(ss==banji)
System.out.println(s);
Iterator<Student> itr=banji.iterator();
while(itr.hasNext()){
Student sss=itr.next();
if(ss==banji)
System.out.println(sss);
}
}
}
}
class p{
public static void main(String[] args){
xuexiao xx=new xuexiao();
xx.xuexiao1();
xx.getStudent(xuexiao,erban);
}//我就是想这么传,但是这是错误的参数,运行就Error,上面的代码我应该怎么写,这里可以这么传?
} |