Here you can find the source of compareLists(List
Parameter | Description |
---|---|
a | a parameter |
b | a parameter |
public static int compareLists(List<String> a, List<String> b)
//package com.java2s; import java.util.List; public class Main { /**/*from w w w . j av a2 s . c o m*/ * compare two lists * @param a * @param b * @return the comparison result */ public static int compareLists(List<String> a, List<String> b) { if (a == b) return 0; if (a != null && b == null) return -1; if (a == null && b != null) return 1; if (a.size() != b.size()) return -1; for (int i = 0; i < a.size(); i++) { final String aval = a.get(i); final String bval = b.get(i); if (aval == null && bval == null) continue; if (aval == null && bval != null) return 1; if (aval != null && bval == null) return -1; final int c = aval.compareTo(bval); if (c != 0) return c; } return 0; } }