AbstractSequentialList equals() method in Java with Example Last Updated : 24 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The equals() method of java.util.AbstractSequentialList class is used to check if this AbstractSequentialList object is equal to the object passed as the parameter. This method returns a boolean value stating the same. Syntax: public boolean equals(Object o) Parameters: This method takes the object o as a parameter to be compared for equality with this list. Returns Value: This method returns true if the specified object is equal to this list. Below are the examples to illustrate the equals() method. Example 1: Java // Java program to demonstrate equals() // method of AbstractSequentialList import java.util.*; public class GFG { public static void main(String[] argv) { // Creating object of AbstractSequentialList<String> AbstractSequentialList<String> arrlist1 = new LinkedList<String>(); // Populating arrlist1 arrlist1.add("A"); arrlist1.add("B"); arrlist1.add("C"); arrlist1.add("D"); arrlist1.add("E"); // print arrlist1 System.out.println("First AbstractSequentialListlist: " + arrlist1); // Creating another object of AbstractSequentialList<String> AbstractSequentialList<String> arrlist2 = new LinkedList<String>(); // Populating arrlist2 arrlist2.add("A"); arrlist2.add("B"); arrlist2.add("C"); arrlist2.add("D"); arrlist2.add("E"); // print arrlist2 System.out.println("Second AbstractSequentialList: " + arrlist2); // comparing first AbstractSequentialList to another // using equals() method boolean value = arrlist1.equals(arrlist2); // print the value System.out.println("Are both list equal: " + value); } } Output: First AbstractSequentialListlist: [A, B, C, D, E] Second AbstractSequentialList: [A, B, C, D, E] Are both list equal: true Example 2: Java // Java program to demonstrate equals() // method of AbstractSequentialList import java.util.*; public class GFG1 { public static void main(String[] argv) { // Creating object of AbstractSequentialList AbstractSequentialList<Integer> arrlist1 = new LinkedList<Integer>(); // Populating arrlist1 arrlist1.add(10); arrlist1.add(20); arrlist1.add(30); arrlist1.add(40); arrlist1.add(50); // print arrlist1 System.out.println("First AbstractSequentialListlist: " + arrlist1); // Creating another object of AbstractSequentialList AbstractSequentialList<Integer> arrlist2 = new LinkedList<Integer>(); // Populating arrlist2 arrlist2.add(10); arrlist2.add(20); arrlist2.add(30); // print arrlist2 System.out.println("Second AbstractSequentialList: " + arrlist2); // comparing first AbstractSequentialList to another // using equals() method boolean value = arrlist1.equals(arrlist2); // print the value System.out.println("Are both list equal: " + value); } } Output: First AbstractSequentialListlist: [10, 20, 30, 40, 50] Second AbstractSequentialList: [10, 20, 30] Are both list equal: false Comment More infoAdvertise with us Next Article AbstractSequentialList lastIndexOf() method in Java with Example C code_r Follow Improve Article Tags : Java Java-Collections Java - util package Java-Functions java-AbstractSequentialList +1 More Practice Tags : JavaJava-Collections Similar Reads AbstractSequentialList in Java with Examples The AbstractSequentialList class in Java is a part of the Java Collection Framework and implements the Collection interface and the AbstractCollection class. This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "s 7 min read AbstractSequentialList size() method in Java with Example The size() method of AbstractSequentialList in Java is used to get the size for this instance of the AbstractSequentialList. It returns an integer value which is the size for this instance of the AbstractSequentialList. Syntax: public int size() Parameters: This method does not accepts any parameter 2 min read AbstractSequentialList conatinsAll() method in Java with Example The containsAll() method of Java AbstractSequentialList is used to check whether two Collections contain the same elements or not. It takes one collection as a parameter and returns True if all of the elements of this collection is present in the other collection. Syntax: public boolean containsAll( 2 min read AbstractSequentialList lastIndexOf() method in Java with Example The lastIndexOf() method of java.util.AbstractSequentialList class is used to return the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i) 2 min read AbstractSequentialList hashCode() method in Java with Example The hashCode() method of AbstractSequentialList in Java is used to get the hashCode value for this instance of the AbstractSequentialList. It returns an integer value which is the hashCode value for this instance of the AbstractSequentialList. Syntax: public int hashCode() Parameters: This function 2 min read AbstractSequentialList retainAll() method in Java with Example The retainAll() method of java.util.AbstractSequentialList class is used to retain from this list all of its elements that are contained in the specified collection. Syntax: public boolean retainAll(Collection c) Parameters: This method takes collection c as a parameter containing elements to be ret 3 min read AbstractSequentialList subList() method in Java with Example The subList() method of AbstractSequentialList in Java is used to get a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural c 2 min read AbstractSequentialList toArray() method in Java with Example The toArray() method of Java AbstractSequentialList is used to form an array of the same elements as that of the AbstractSequentialList. Basically, it copies all the element from a AbstractSequentialList to a new array. Syntax: Object[] arr = AbstractSequentialList.toArray() Parameters: The method d 2 min read AbstractSequentialList toArray(T[]) method in Java with Example The toArray(arr[]) method of AbstractSequentialList class in Java is used to form an array of the same elements as that of the AbstractSequentialList. It returns an array containing all of the elements in this AbstractSequentialList in the correct order; the run-time type of the returned array is th 4 min read AbstractSequentialList contains() method in Java with Example The contains() method of Java AbstractSequentialList is used to check whether an element is present in a Collection or not. It takes the element as a parameter and returns True if the element is present in the collection. Syntax: public boolean contains(Object element) Parameters: The parameter elem 2 min read Like