List comparison
In this chapter you will learn:
Compare two Lists
boolean equals(Object o)
Compares the specified object with this list for equality.
import java.util.ArrayList;
import java.util.List;
/*from j a v a2 s. com*/
public class Main {
public static void main(String[] args) {
List list = new ArrayList();
list.add("1");
list.add("2");
list.add("3");
list.add("java2s.com");
List list1 = new ArrayList();
list1.add("1");
list1.add("2");
list1.add("3");
list1.add("java2s.com");
System.out.println("List has:" + list);
System.out.println("List1 has:" + list);
boolean b = list.equals(list1);
System.out.println(b);
}
}
The output:
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » List