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;
?? ?}
來源:java中把map轉換成list_weixin_33734785的博客-CSDN博客
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的java中把map转换成list的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 撞车了保险公司全赔吗
- 下一篇: java 三种将list转换为map的方