- Thread Author
- #1
I have classes defined like below:
I tested them with the following code:
For KA, either no-arg constructor or constructor with totally different arguments, I would get they are equal.
I want KA to be using the default equal method of Object class which is comparing the object memory addresses.
What is wrong here?
Code:
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public abstract class A {
private Enum myEnum;
}
Code:
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public class KA extends A {
private MyPackage pck;
private String field1;
private String field2;
}
Code:
KA ka1 = new KA();
KA ka2 = new KA();
System.out.println("Object equal: " + ka1.equals(ka2));
I want KA to be using the default equal method of Object class which is comparing the object memory addresses.
What is wrong here?