StringWriter equals() method in Java with Example
The Java.io.StringWriter.equals(Object obj) method of StringWriter class in Java is used to check whether the two instances of StringWriter are equal or not. It returns a boolean stating whether they are equal or not.
public boolean equals(StringWriter second_StringWriter)
Parameters: This method accepts a mandatory parameter second_StringWriter which refers to the second StringWriter to be compared to the first StringWriter.
Return value: The method returns true if the equality holds and both the objects and StringWriter are equal else it returns false.
Below programs are used to illustrate the working of the java.io.StringWriter.elements() method:
StringWriter 1: GeeksForGeeks StringWriter 2: GFG Are both of them equal? false
StringWriter 1: GFG StringWriter 2: GFG Are both of them equal? false
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.