CompareUtil01
package com.test.demo.autodemo;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CompareUtil01 {
public static boolean compareMap(List> list, List> list2) {
boolean isSuccess =false;
long st = System.nanoTime();
if(list==null||list.size()==0){
System.out.println("list is null ");
return isSuccess;
}
if(list2==null||list2.size()==0){
System.out.println("list2 is null ");
return isSuccess;
}
if (list.size() != list2.size()) {
System.out.println("table has different row count " + (System.nanoTime() - st));
return isSuccess;
}
int i=0;
for(Map map:list){
for (Map.Entry entry1 : map.entrySet()) {
String m1key = entry1.getKey();
Object m1value = entry1.getValue();
Map map2 = list2.get(i);
if (!map2.containsKey(m1key)){
System.out.println("lise2表不存在这样的列字段+"+m1key);
}else {
System.out.println("baohan");
System.out.println("m1key="+m1key+" ,m1Value="+m1value);
if(m1value==null&&map2.get(m1key)==null){
continue;
}else {
System.out.println("m1value="+m1value+" ,map2.get(m1key)="+map2.get(m1key));
if (m1value.equals(map2.get(m1key))){
System.out.println("相等");
isSuccess =true;
}else {
System.out.println("不相等");
isSuccess =false;
}
}
}
++i;
}
}
return isSuccess;
}
public static void main(String[] args) {
Map stringObjectMap =new HashMap<>();
stringObjectMap.put("name",30);
stringObjectMap.put("name",40);
System.out.println(stringObjectMap.size());
}
}