<div dir="ltr">My (formal) Java education started with a record-less version of the following as the collection mechanism of choice<br><br><font face="monospace">sealed interface LList<T> {<br>    int size();<br>}<br>record Empty<T>() implements LList<T> {<br>    <a class="gmail_plusreply" id="plusReplyChip-0">@Override<br></a>    public int size() {<br>        return 0;<br>    }<br>}<br>record NotEmpty<T>(T first, LList<T> rest) </font><span style="font-family:monospace">implements LList<T></span><font face="monospace"> {</font><br><font face="monospace">    </font><a class="gmail_plusreply" id="plusReplyChip-1" style="font-family:monospace">@Override<br></a><font face="monospace">    public int size() {</font><br><font face="monospace">        return 1 + rest.size();</font><br><font face="monospace">    }</font><br><font face="monospace">}</font><br><br><font face="arial, sans-serif">With every operation being defined recursively and (to start) every list implementation being bespoke without generics.</font><br><br><font face="arial, sans-serif">Nowadays I would think this would be easier to teach since it would be expressible without instance methods. </font><br><br><font face="monospace">sealed interface LList<T> {}<br>record Empty<T> () implements List<T> {}<br>record NotEmpty<T>(T first, LList<T> rest) implements LList<T> {}<br><br>int size(LList<T> list) {<br>    return switch (list) {<br>        case Empty() -> 0;<br>        case NotEmpty(_, rest) -> 1 + size(rest);<br>    };<br>}</font><br><br><font face="arial, sans-serif">Which is all to say that I think there are <i>some</i> benefits to starting from a way you "have to unlearn" later.<br><br>One pro of arrays is that they are mutable and, in the journey that starts with standard loops instead of recursion, it functions well to demonstrate mutable aliasing. The cons are what you are all describing.</font></div><div dir="auto"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 29, 2025, 11:52 AM Brian Goetz <<a href="mailto:brian.goetz@oracle.com" target="_blank">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>
    <br>
    <br>
    <blockquote type="cite">
      <div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
        <div>
          <div>I agree,</div>
          <div>arrays are fully weird in Java, they don't behave like
            proper objects (no equals/hahCode/toString), they have a
            weird hierarchy, they are always mutable and they do not
            work properly with generics too.</div>
          <div><br>
          </div>
          <div>So they are not simple to use, they are low level
            primitives, not something you do not want introduce early in
            the learning process.</div>
        </div>
      </div>
    </blockquote>
    <br>
    Preach it, brother!  <br>
    <br>
    I understand the tendency to want to teach "from the ground up", but
    starting with arrays (like with static methods) is just teaching
    habits that need to be unlearned.  <br>
    <br>
    <br>
  </div>

</blockquote></div>