<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<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>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<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">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></div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</body>
</html>