<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Chen Liang" <chen.l.liang@oracle.com><br><b>To: </b>"Ethan McCue" <ethan@mccue.dev>, "David Alayachew" <davidalayachew@gmail.com><br><b>Cc: </b>"amber-dev" <amber-dev@openjdk.org><br><b>Sent: </b>Sunday, June 29, 2025 4:54:36 PM<br><b>Subject: </b>Re: IO.println behavior on char[]<br></blockquote></div><div><style style="display:none;"> P {margin-top:0;margin-bottom:0;} </style></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Good observation -however, I do think disclosing that Java arrays are storage objects instead of functional objects like a list should be done as early as possible to Java learners. Doing so through the lack of toString override on arrays evident in IO.println
is a good way.</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
(On a side note, the simplified main hides the argument array, which allows us to introduce array later into the learning process)</div></blockquote><div><br></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 data-mce-bogus="1"></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><br data-mce-bogus="1"></div><div>regards,</div><div>Rémi</div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">
<hr style="display:inline-block;width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amber-dev <amber-dev-retn@openjdk.org> on behalf of Ethan McCue <ethan@mccue.dev><br><b>Sent:</b> Saturday, June 28, 2025 12:05 PM<br><b>To:</b> David Alayachew <davidalayachew@gmail.com><br><b>Cc:</b> amber-dev <amber-dev@openjdk.org><br><b>Subject:</b> Re: IO.println behavior on char[]</font>
<div> </div>
</div>
<div>
<div dir="auto">Yeah it's easy enough to work around, just noting the divergence </div>
<br>
<div class="x_gmail_quote x_gmail_quote_container">
<div dir="ltr" class="x_gmail_attr">On Sat, Jun 28, 2025, 12:42 PM David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank">davidalayachew@gmail.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="auto">
<p dir="ltr">Ah, I see you were referring to System.out. </p>
<p dir="ltr">Adding that overload makes sense. Though, I would rather it default to doing Arrays.toString, as opposed to just the one overload. That way, all arrays would be printable.</p>
<p dir="ltr">That was a common pain point for my students. Try to print an array of objects, and they only get an array address. And since they don't recognize that it's an address, it created some confusing bugs, as they think the hexadecimal address string
was from previous or following print statements.</p>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Sat, Jun 28, 2025, 12:36 PM David Alayachew <<a href="mailto:davidalayachew@gmail.com" rel="noreferrer noreferrer" target="_blank">davidalayachew@gmail.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<p dir="ltr">Is there a char[] overload? I just checked the javadoc for 24 and 25, and I only see Object, String, and no-arg overloads. Not char[].</p>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Sat, Jun 28, 2025, 6:40 AM Ethan McCue <<a href="mailto:ethan@mccue.dev" rel="noreferrer noreferrer noreferrer" target="_blank">ethan@mccue.dev</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">I was going through some examples in my writing and noticed that<br>
<br>
IO.println(new char[] { 'a', 'b' });<br>
<br>
will hit the Object overload of System.out.println and not the char[] overload<br>
<br>
This breaks a few of my examples <a href="https://javabook.mccue.dev/arrays/aliasing" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">https://javabook.mccue.dev/arrays/aliasing</a><br data-mce-bogus="1"></div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div><br></blockquote></div></div></body></html>