The example of this article tells the way Java compares the value of the two LIST. Share it for everyone for your reference. The specifics are as follows:
Suppose the two queues {1,2,3,4} and {4,3,2,1} are used. This method is used to compare whether the values contained in these two queues are equal
/** * queue comparison * @param <t> * @param a * @param b * @Return */public static <T extends comparable <T >> Boolean compare {if (a.Size ()!! = B.Size ()) Return false; Collections.sort (a); Collections.sort (b); for (int i = 0; i <.Size ()); i ++) {if (! A.get (i) .equals (b.get (i))) Return false;} Return True;} // The test method is as follows: Public Static void Main (string [] args) {list <integer> a = Arrays.aslist (1,2,3,4); list <integer> b = Arrays.aslist (4,3,2,1); System.out.println (compare (a, b));}/ /Execute results TRUEIt is hoped that this article is helpful to everyone's Java program design.