Here you can find the source of stringListEquals(List
Parameter | Description |
---|---|
left | the left |
right | the right |
public static boolean stringListEquals(List<String> left, List<String> right)
//package com.java2s; /**// ww w . j a v a 2s.com * Licensed under Apache License v2. See LICENSE for more information. */ import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { /** * Tests if two arrays of strings have the same members irrespective of order. * * @param left the left * @param right the right * @return the result */ public static boolean stringListEquals(List<String> left, List<String> right) { if (left.size() != right.size()) { return false; } if (left.size() == 0) { return true; } List<String> copyOfLeft = new ArrayList<String>(left); List<String> copyOfRight = new ArrayList<String>(right); Collections.sort(copyOfLeft); Collections.sort(copyOfRight); for (int i = 0; i < left.size(); i++) { if (!copyOfLeft.get(i).equals(copyOfRight.get(i))) { return false; } } return true; } }