The equals() method of java.text.ParsePosition class is used to check if both the ParsePosition objects are same or not. Syntax:
public boolean equals(Object obj)
Parameter: This method takes ParsePosition objects which will be compared with the current ParsePosition object. Return Value: if both the ParsePosition objects are equal to each other than it will return true otherwise false. Below are the examples to illustrate the equals() method: Example 1:Â
Java
// Java program to demonstrate// equals() methodÂ
import java.text.*;import java.util.*;import java.io.*;Â
public class GFG {Â Â Â Â public static void main(String[] argv)Â Â Â Â {Â Â Â Â Â Â Â Â try {Â
            // Creating and initializing            // new ParsePosition Object            ParsePosition pos_1                = new ParsePosition(0);Â
            // Creating and initializing            // new ParsePosition Object            ParsePosition pos_2                = new ParsePosition(0);Â
            // compare both object            // using equals() method            boolean i = pos_1.equals(pos_2);Â
            // display result            if (i)                System.out.println(                    "pos_1 is equals to pos_2");            else                System.out.println(                    "pos_1 is not equal to pos_2");        }Â
        catch (ClassCastException e) {Â
            System.out.println(e);        }    }} |
pos_1 is equals to pos_2
Example 2:Â
Java
// Java program to demonstrate// equals() methodÂ
import java.text.*;import java.util.*;import java.io.*;Â
public class GFG {Â Â Â Â public static void main(String[] argv)Â Â Â Â {Â Â Â Â Â Â Â Â try {Â
            // Creating and initializing            // new ParsePosition Object            ParsePosition pos_1                = new ParsePosition(0);Â
            // Creating and initializing            // new ParsePosition Object            ParsePosition pos_2                = new ParsePosition(1);Â
            // compare both object            // using equals() method            boolean i = pos_1.equals(pos_2);Â
            // display result            if (i)                System.out.println(                    "pos_1 is equals to pos_2");            else                System.out.println(                    "pos_1 is not equal to pos_2");        }Â
        catch (ClassCastException e) {Â
            System.out.println(e);        }    }} |
pos_1 is not equal to pos_2
Reference: https://docs.oracle.com/javase/9/docs/api/java/text/ParsePosition.html#equals-java.lang.Object-
