java中把map转换成list

private String key;
	private String value;
	
	//把map转换成list的公共方法
	public static List mapToList(Map map){
		List list=new ArrayList();
		Iterator it=map.keySet().iterator();
		while(it.hasNext()){
			String key=it.next().toString();
			ExponseConstants exponseConstants=new ExponseConstants();
			exponseConstants.setKey(key);
			exponseConstants.setValue(map.get(key).toString());
			list.add(exponseConstants);
		}
		return list;
	}
	
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public String getValue() {
		return value;
	}
	public void setValue(String val) {
		this.value = val;
	}

转载于:https://my.oschina.net/mapsh/blog/598141

猜你喜欢

转载自blog.csdn.net/weixin_33734785/article/details/91691138