- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The equals() method of AbstractSequentialList in Java
The equals() method is inherited from the AbstractList class in Java. It is used to check the object for equality with this list. It returns TRUE if the object is equal to this list, else FALSE is returned.
The syntax is as follows −
public boolean equals(Object o)
Here, o is the object to be compared for equality with this list.
To work with the AbstractSequentialList class in Java, you need to import the following package
import java.util.AbstractSequentialList;
The following is an example to implement AbstractSequentialList equals() method in Java
Example
import java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList<Integer> absSequential1 = new LinkedList<>(); absSequential1.add(110); absSequential1.add(320); absSequential1.add(400); absSequential1.add(550); absSequential1.add(600); absSequential1.add(700); absSequential1.add(900); System.out.println("Elements in the AbstractSequentialList1 = "+absSequential1); AbstractSequentialList<Integer> absSequential2 = new LinkedList<>(); absSequential2.add(110); absSequential2.add(320); absSequential2.add(400); absSequential2.add(550); absSequential2.add(600); absSequential2.add(700); absSequential2.add(900); System.out.println("Elements in the AbstractSequentialList2 = "+absSequential2); System.out.println("Both the AbstractSequentialList2 equals? "+ absSequential1.equals(absSequential2)); } }
Output
Elements in the AbstractSequentialList1 = [110, 320, 400, 550, 600, 700, 900] Elements in the AbstractSequentialList2 = [110, 320, 400, 550, 600, 700, 900] Both the AbstractSequentialList2 equals? True
Advertisements