• 将对象放入到map中,找出map中指定的某个属性值并放在一个list中


    package facadeTest.mapAndObject;
    
    import java.util.ArrayList;
    import java.util.List;
    
    /**
     * 
     * 将对象放入到map中,找出map中指定的某个属性值并放在一个list中
     */
    public class TargetAndMapChange {
    	public static void main(String[] args) {
    		Safc safc = new Safc();
    		safc.setAccident("意外险");
    		safc.setProperties("财产险");
    		safc.setForce("商业险");
    		Safc safc01 = new Safc();
    		safc01.setAccident("意外险01");
    		safc01.setProperties("财产险01");
    		safc01.setForce("商业险01");
    		// Map<String,Object> map = new HashMap<String,Object>();
    		List<Safc> list = new ArrayList<Safc>();
    		List<String> list01 = new ArrayList<String>();
    		list.add(safc);
    		list.add(safc01);
    		System.out.println(list);
    		for (Safc safc02 : list) {
    			// 对象不能强转成map,直接get出key对应的value的值
    			// map = (Map<String, Object>) safc02;
    			String value = safc02.getProperties();
    			System.out.println(value);
    			if ("财产险".equals(value)) {
    				list01.add(value);
    			}
    		}
    		System.out.println(list01);
    	}
    }
    
    package facadeTest.mapAndObject;
    
    /**
     * 险种实体类
     * 
     */
    public class Safc {
    	private String accident;
    	private String properties;
    	private String force;
    
    	public String getAccident() {
    		return accident;
    	}
    
    	public void setAccident(String accident) {
    		this.accident = accident;
    	}
    
    	public String getProperties() {
    		return properties;
    	}
    
    	public void setProperties(String properties) {
    		this.properties = properties;
    	}
    
    	public String getForce() {
    		return force;
    	}
    
    	public void setForce(String force) {
    		this.force = force;
    	}
    
    	@Override
    	public String toString() {
    		return "Safc [accident=" + accident + ", properties=" + properties
    				+ ", force=" + force + "]";
    	}
    
    }
    

      

      

  • 相关阅读:
    [转]Oracle 语法之 OVER (PARTITION BY ..) 及开窗函数
    oracle本月、上月、去年
    Oracle 物理视图刷新报错ORA-00942
    [转]Oracle trunc()函数的用法
    [转]物化视图创建 及 刷新机制修改
    [转]oracle制定定时任务(dbms_jobs)
    【转】Windows平台下的Subversion安装配置新手指南
    【转】数字签名与数字证书
    [转]SQL 常用函数及示例
    【转】视图、索引、存储过程 、触发器、游标及事务
  • 原文地址:https://www.cnblogs.com/qqyong123/p/8478437.html
Copyright © 2020-2023  润新知