Skip to content

Instantly share code, notes, and snippets.

@TGITS
Created January 22, 2022 15:40
Show Gist options
  • Save TGITS/c855de19a7519ce4db7a71ddcb827789 to your computer and use it in GitHub Desktop.
Save TGITS/c855de19a7519ce4db7a71ddcb827789 to your computer and use it in GitHub Desktop.
Un premier exemple de record avec utilisation de la méthode toString et d'un accesseur
//A exécuter sous JShell : /open RecordExampleScript_1.java
public record House(String name, String seat, String sigil, String familyWords) {
}
var house = new House("Stark", "Winterfell", "A Gray Direwolf", "Winter is coming");
System.out.println(house); // Utilisation implicte de la méthode toString
System.out.println(house.seat()); // Utilisation d'un accesseur
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment