Online Java Compiler By
JavaTpoint.com
public class JavaObjectequalsExample1 { static int a = 10, b=20; int c; // Constructor JavaObjectequalsExample1() { System.out.println("Addition of 10 and 20 : "); c=a+b; System.out.println("Answer : "+c); } // Driver code public static void main(String args[]) { System.out.println("1st object created..."); JavaObjectequalsExample1 obj1 = new JavaObjectequalsExample1(); System.out.println("2nd object created..."); JavaObjectequalsExample1 obj2 = new JavaObjectequalsExample1(); System.out.println("Objects are equal:" + obj1.equals(obj2)); } }
Output