//部门类publicclassDeptVo{privateStringdeptName;privateintnum;publicDeptVo(StringdeptName,intnum){this.deptName=deptName;this.num=num;}publicStringgetDeptName(){returndeptName;}publicvoidsetDeptName(StringdeptName){this.deptName=deptName;}publicintgetNum(){returnnum;}publicvoidsetNum(intnum){this.num=num;}}//主函数importjava.util.HashMap;importjava.util.Map;publicclassTest{publicstaticvoidmain(String[]args){MapdeptVoMap=newHashMap();deptVoMap.put("财务部",newDeptVo("财务部",5));deptVoMap.put("信息技术部",newDeptVo("信息技术部",10));deptVoMap.put("设备管理部",newDeptVo("设备管理部",15));intnum=deptVoMap.get("信息技术部").getNum();System.out.println(num);}}
代码以上,望采纳。 |