I have 2 arraylists of string object.
List sourceList = new ArrayList();
List destinationList = new ArrayList
Convert the List in to String and check whether the Strings are same or not
import java.util.ArrayList;
import java.util.List;
/**
* @author Rakesh KR
*
*/
public class ListCompare {
public static boolean compareList(List ls1,List ls2){
return ls1.toString().contentEquals(ls2.toString())?true:false;
}
public static void main(String[] args) {
ArrayList one = new ArrayList();
ArrayList two = new ArrayList();
one.add("one");
one.add("two");
one.add("six");
two.add("one");
two.add("two");
two.add("six");
System.out.println("Output1 :: "+compareList(one,two));
two.add("ten");
System.out.println("Output2 :: "+compareList(one,two));
}
}