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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -