Here you can find the source of compare(List
Parameter | Description |
---|---|
strList1 | List<String> |
strList2 | List<String> |
@Deprecated public static boolean compare(List<String> strList1, List<String> strList2)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { /**//from w w w . jav a 2 s . c om * * Compare this two list whether equal * * @param strList1 List<String> * @param strList2 List<String> * @return boolean */ @Deprecated public static boolean compare(List<String> strList1, List<String> strList2) { List<String> list1 = strList1 == null ? new ArrayList<String>() : strList1; List<String> list2 = strList2 == null ? new ArrayList<String>() : strList2; if (list1.size() != list2.size()) { return false; } for (String str1 : list1) { boolean isFound = false; int index = 0; for (String str2 : list2) { if (str1.equals(str2)) { isFound = true; break; } index++; } if (isFound) { list2.remove(index); } else { return false; } } if (list2.isEmpty()) { return true; } return false; } /** * return true value whether string is empty. * * @param string String The source string * @return boolean */ public static boolean isEmpty(String string) { return string == null || string.trim().length() == 0; } public static String trim(String string) { if (string == null) { return null; } return string.trim(); } }