<div dir="ltr"><div class="gmail_default" style="font-family:monospace">Thanks <a class="gmail_plusreply" id="plusReplyChip-2" href="mailto:robbepincket@live.be" tabindex="-1">@Robbe Pincket</a> and <a class="gmail_plusreply" id="plusReplyChip-3" href="mailto:brian.goetz@oracle.com" tabindex="-1">@Brian Goetz</a>. My understanding of the examples was a little off.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">So, the difference between records and carrier classes is that carrier classes force you to describe the internal state representation everytime, whereas records can derive that from the stuff in parentheses.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">For example, carrier classes don't have a "default" internal representation that you can override -- you must provide the internal representation every time. Whether the internal representation is mutable fields or immutable, whether the internal representation is private or package-protected or protected, etc. Carrier classes give you no defaults on the internal field representation -- you must decide all of that <b><i>explicitly</i></b>.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Upon doing so, then carrier classes can give you basically every other default for free, straight from the records handbook. But it's only the internal field representation where you are on your own.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Do I have it right this time? Obviously, there are things like the class must be final and extend Record, but I'm more focusing on the internal state details.</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Jan 14, 2026 at 8:00 PM Brian Goetz <<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
<blockquote type="cite">
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
AFAIK `final class Point2D(int x, int y) {}` does not work? You
need the following:</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
```java</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
class Point(int x, int y) {</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
private final component int x;</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
private final component int y;</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
}</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
```</div>
<div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
So that's the benefit. No need to specify the fields a second
time.</div>
<br>
</blockquote>
<br>
If you want it to be equivalent to the record declaration, you also
have to make the class final (and extend Record.)
</div>
</blockquote></div>