1.工作当中例如获取用户地址,例如省份--城市--县--镇数据时,最好用类分装,不要用map;
类看上去代码更简洁,而且不会出现map那样按照key排序的问题
Long l1 = Calendar.getInstance().getTimeInMillis();
for (int i = 0; i < 100000; ++i) {
Map map = new HashMap();
map.put("1", "1");
map.get("1");
}
Long l2 = Calendar.getInstance().getTimeInMillis();
System.out.println(l2 - l1);
for (int i = 0; i < 100000; ++i) {
Test test = new Test();
test.setProvinceName("1");
test.getProvinceName();
}
Long l3 = Calendar.getInstance().getTimeInMillis();
System.out.println(l3 - l2);
}
2.
public static void main(String[] args) {
3.上面例子结果为:
72
34
72
34