Home » Tip Bank » Java
  • Comment on this Article
Language: Java
Expertise: Intermediate
Apr 1, 2020

WEBINAR:

On-Demand

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


Watch

Understandng Objects.deepEquals

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

*/
M S Sridhar
 
Submit a Tip
Browse "Java" Tips
Browse All Tips
javascriptweekly.com
w3.org