遍历List

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Client {

    public static void main(String[] args) {

        //HashMap无序,TreeMap有序
        Map map = new HashMap();
        map.put("AR01", "hello");
        map.put("AR02", 2017);
        map.put("AR03", "world");
        map.put("AR04", 1000);

        List> testList = new ArrayList>();
        testList.add(map);

        for (Map m : testList) {
            for (String k : m.keySet()) {
                System.out.println(k + " : " + m.get(k));
            }

        }
    }

}

输出结果:
AR03 : world
AR04 : 1000
AR01 : hello
AR02 : 2017

你可能感兴趣的:(Java工具类)