📄 mapdemo.java
字号:
import java.util.*;
public class MapDemo implements IMapDemo
{
Map nt=new TreeMap();
public Student tobePojo(String s){
String now[]=s.split("[:]");
StudentDemo test=new StudentDemo();
Address b=test.toBeAddress(now[4],now[5],now[6],Integer.parseInt(now[7]));
Student a=test.toBePojo(now[1],Integer.parseInt(now[2]),Boolean.getBoolean(now[3]),Integer.parseInt(now[0]),b);
return a;
}
//调用StudentDemo的方法!返回学生对象
//学号:姓名:年龄:性别:国家:城市:街道:门牌
//1:jim:25:true:China:ShangHai:laoshanDOnglu:521
//2:roger:30:false:China:beijing:laoshanDOnglu:921
//int x=Integer.parseInt("1");
//boolean b=Boolean.parseBoolean("true");
public void addToMap(Student student){
nt.put(student.getCode(),student);
}
//把学生对象根据键值对应放入Map(字段)中,学号为键,学生对象为值
public Object getFromMap(int code){
return nt.get(code);
}
// 通过学生学号把学生对象返回出来
public void printMap(){
Set s=nt.keySet();
Iterator iter=s.iterator();
StudentDemo test=new StudentDemo();
while(iter.hasNext()){
test.printStudent((Student)nt.get(iter.next()));
}
}
//通过keySet方法得到键的集合,通过键访问学生对象,
//并调用StudentDemo的PrintStudent方法打印学生对象
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -