Spring与集合
来源:互联网 发布:淘宝站外计销量的网站 编辑:程序博客网 时间:2024/05/16 19:28
package com.hsp.collection;import java.util.Enumeration;import java.util.Iterator;import java.util.Map;import java.util.Properties;import java.util.Map.Entry;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class App1 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub ApplicationContext ac=new ClassPathXmlApplicationContext("com/hsp/collection/beans.xml"); Department department=(Department) ac.getBean("department"); System.out.println(department.getName()); for(String emName:department.getEmpName()){ System.out.println(emName); } System.out.println("**********通过list集合取出数据*****"); for(Employee e : department.getEmpList()){ System.out.println("name="+e.getName()+" "+e.getId()); } System.out.println("**********通过set集合取出数据*****"); for(Employee e : department.getEmpsets()){ System.out.println("name="+e.getName()); } System.out.println("*******通过map集合取出数据 迭代器****"); //1.迭代器 Map<String,Employee> empmaps=department.getEmpMaps(); Iterator it=empmaps.keySet().iterator(); while(it.hasNext()){ String key=(String) it.next(); Employee emp=empmaps.get(key); System.out.println("key="+key+" "+emp.getName()); } System.out.println("*******通过map集合取出数据 简洁方法****"); //2.简洁方法 for(Entry<String,Employee> entry1:department.getEmpMaps().entrySet()){ System.out.println(entry1.getKey()+" "+entry1.getValue().getName()); } System.out.println("*****通过Propertis取出数据*****"); Properties pp=department.getPp(); //System.out.println(pp.get("pp1").toString()); for(Entry<Object,Object> entry:pp.entrySet()){ System.out.println(entry.getKey().toString()+" "+entry.getValue().toString()); } System.out.println("*****通过Enumeration取出*****"); Enumeration en= pp.keys(); while(en.hasMoreElements()){ // Entry<Object,Object> elment= (Entry<Object, Object>) en.nextElement(); // System.out.println(elment.getKey()+" "+elment.getValue()); String key=(String) en.nextElement(); System.out.println(key+" "+pp.getProperty(key)); } }}
阅读全文
0 0
- Spring与集合
- spring 与jedis2.7 集合
- Spring与JDBC集合以及事物处理
- spring集合
- Spring MVC同时接收一个对象与List集合对象
- Spring、SpringMVC与mybatis的集合的配置文档
- 集合与通用集合
- 集合与通用集合
- Spring 资料集合
- spring 集合注入方式
- spring集合注入
- Spring -------集合对象注入
- Spring装配集合属性
- Spring错误集合
- spring中的集合装配
- Spring注入集合
- spring中的装配集合
- Spring集合注入
- SSL握手过程实例分析
- json转map
- 安全框架--shiro
- Kotlin(三)
- Ubuntu14.04_64编译libiconv出问题 ./stdio.h:1010:1: error: 'gets' undeclared here (not in a function)
- Spring与集合
- 模板实现冒泡排序
- yum命令后出现libldap-2.4.so.2: cannot open shared object file
- eclipse debug URLClassPath.getLoader(int) file
- 命令行使用wget下载百度云资源
- debian 程序开机自动启动设置
- 做微信扫码支付接口,二维码图片显示的是二进制文件的解决方案
- 关于负载均衡的三种传输模式(反向代理,透传,三角)
- SSL握手过程