dcsimg
comparing two String arrays using containsAll
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   neal_ravindran
Posted On:   Tuesday, April 24, 2001 09:11 AM

Using Java 2 Collections how can I compare (the code to) two String arrays
That is I have the follwiing:-
String[] a1={"man","cow","foot","mouth"};
String[] a2={"man","cow","foot","mouth"};
How would I be able to compare these two and say that
they contain identical Strings?(using Java2 collections and using containsAll)

Re: comparing two String arrays using containsAll

Posted By:   John_Zukowski  
Posted On:   Tuesday, April 24, 2001 05:19 PM

The Arrays class has an equals() method that will check for equality of elements. If you want to use containsAll() in case order doesn't matter, then call containsAll() on both arrays.
About | Sitemap | Contact