dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Understandng Objects.deepEquals

See how to take advantage of the deepEquals() method.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


We understand how the equals() method works. There is a more elaborate method called deepEquals() that compares in-depth details.

The basic usage is described below. Let's explore more using these as examples.

import java.util.Objects;

public class DeepEquals
{
   public static void main(String args[])
   {
      DeepEquals deepEquals = new DeepEquals();
      deepEquals.proceed();
   }
   
   private void proceed()
   {
      System.out.println("Objects.deepEquals(1,1): " + Objects.deepEquals(1,1));
      System.out.println("Objects.deepEquals(1,2): " + Objects.deepEquals(1,2));
      System.out.println("Objects.deepEquals(\"abc\",\"abc\"): " + Objects.deepEquals("abc","abc"));
      System.out.println("Objects.deepEquals(\"aa\",\"ab\"): " + Objects.deepEquals("aa","ab"));
   }
}

/*

Expected output:

[root@mypc]# java DeepEquals
Getting handle of runtime Console
Got handle of runtime Console
You can now use runtimeConsole object to perform actions of your choice on java.io.Console

*/

 

Visit the DevX Tip Bank

 





   
Sridhar M S. is a Java developer from Bangalore, India. He holds a master's degree in Computer Science.
Thanks for your registration, follow us on our social networks to keep up-to-date