XhstormR
//部门类
public class DeptVo {
private String deptName;
private int num;
public DeptVo(String deptName, int num) {
this.deptName = deptName;
this.num = num;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}
//主函数
import java.util.HashMap;
import java.util.Map;
public class Test {
public static void main(String[] args) {
Map<String, DeptVo> deptVoMap = new HashMap<>();
deptVoMap.put("财务部", new DeptVo("财务部", 5));
deptVoMap.put("信息技术部", new DeptVo("信息技术部", 10));
deptVoMap.put("设备管理部", new DeptVo("设备管理部", 15));
int num = deptVoMap.get("信息技术部").getNum();
System.out.println(num);
}
}代码以上,望采纳。