ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
Student student = (Student) ac.getBean("student");
System.out.println("name "+student.getName());
//从 数组中循环取值;
System.out.println("*******************从 数组中循环取值********************");
for (Object crouse : student.getCarry()){
System.out.println("课程有"+crouse.toString());
}
//从 Set集合中循环取值;
System.out.println("*******************从 Set集合中循环取值********************");
for (String crouse : student.getCset()){
System.out.println("课程有"+crouse);
}
//从 List集合中循环取对象;
System.out.println("*******************从 List集合中循环取对象********************");
for (Crouse crouse : student.getClist()){
System.out.println("课程有"+crouse.getName());
}
//从 Map集合中循环取键值对;
System.out.println("*******************从 Map集合中循环取键值对********************");
for (Entry<String, Crouse> entry : student.getCmap().entrySet()){
System.out.println("课程有"+entry.getKey()+" "+entry.getValue().getName());
}
//从 Properties中循环取键值对 与map不同,Properties中的键值对都为字符串;
System.out.println("*******************从Properties中循环取键值对********************");
//方法1;
Properties cpp = student.getCpp();
Enumeration<Object> en = cpp.keys();
while(en.hasMoreElements()){
String key = (String) en.nextElement();
System.out.println("课程有"+key+" "+cpp.getProperty(key));
}
//方法2;
for (Entry<Object, Object> entry : cpp.entrySet()){
System.out.println("课程有"+entry.getKey()+" "+entry.getValue());
}