java - how to cmpare the values of Arraylists -
how can compare values of 2 array lists example :
arraylist = new arraylist<string>(); a.add("1"); a.add("2"); a.add("3"); arraylist b = new arraylist<string>(); b.add("3"); b.add("2"); b.add("1"); system.out.println(areequal(a, b));
should print true , because values of in b.
thanks in advance
if ( a.containsall(b) && (a.size() == b.size() ) )
edit: if contains more elements b, containsall still return true , if want test absolute equality, size comparison necessary.
edit #2: assumes , b contains unique entries. if there duplicates, @robin , @matti have referred to, more complicated depending on ops definition of equality.
Comments
Post a Comment