Last active
September 4, 2024 13:29
-
-
Save Sedose/d0c1051cb71f915ac277bbd1f5f7b3a2 to your computer and use it in GitHub Desktop.
Java record instances are equal by the record members
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Objects; | |
private record AddressIdentity( | |
String city, | |
String streetName, | |
String streetNumber | |
) {} | |
void main() { | |
var first = new AddressIdentity("Kyiv", "Babusia", "12345"); | |
var second = new AddressIdentity("Kyiv", "Babusia", "12345"); | |
System.out.println(STR."The record instances must be equal. Expected true. Actual: \{Objects.equals(first, second)}"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run open terminal and run
java --enable-preview --source 22 Main.java