JShell: representation of array values

Robert Field robert.field at oracle.com
Thu Sep 22 06:48:49 UTC 2016


Thanks Cay, Michael, Remi, Anna, and Ben for the feedback!

Just pushed it!

Anna: responding under separate thread.

Robert

On 09/21/16 23:07, Ben Evans wrote:
> Hi Robert,
>
> Some feedback from my wife, who's currently writing some introductory
> material for absolute beginners in Java (& programming as a whole) -
> she uses jshell as the very first thing that learners meet and had
> this to say:
>
>> seeing a visual representation of the array like that would be a great help!
>> (Right now you have to use iterations to see what's in the array, and that's brining in logic far earlier than I'd like)
>> I really liked in earlier versions where it returned a type as well as a result - helps learners get to grips with java as typed language.
>> (Also makes it easier for kids who are used to calculators to understand why 4/3 returns 1, not 1.333334!)
> If the usage of jshell for beginners is a big aim of the project
> (something like Swift Playgrounds), Anna & I would be happy to help
> review features & provide more feedback with that audience in mind.
>
> Thanks,
>
> Ben
>
>
> On Thu, Sep 22, 2016 at 6:46 AM, Robert Field <robert.field at oracle.com> wrote:
>> JavaOne demos made it clear we need a friendlier representation of array
>> values.
>>
>> Current --
>>
>> jshell> new String[] { "hi", "low", null }
>> $2 ==> [Ljava.lang.String;@ae45eb6
>>
>> jshell> new char[] { 'a', 34, 77 }
>> $3 ==> [C at 27efef64
>>
>> I'm proposing this --
>>
>> jshell> new int[4]
>> $1 ==> int[4] { 0, 0, 0, 0 }
>>
>> jshell> new int[0]
>> $2 ==> int[0] {  }
>>
>> jshell> new String[] { "hi", "low", null }
>> $3 ==> String[3] { "hi", "low", null }
>>
>> jshell> new char[] { 'a', 34, 77 }
>> $4 ==> char[3] { 'a', '"', 'M' }
>>
>> jshell> new int[][] { new int[] {44, 55}, new int[] {88,99}}
>> $5 ==> int[][2] { int[2] { 44, 55 }, int[2] { 88, 99 } }
>>
>> jshell> new Object[] { "howdy", new int[] { 33, 44, 55 }, new String[] {
>> "up", "down" }}
>> $6 ==> Object[3] { "howdy", int[3] { 33, 44, 55 }, String[2] { "up", "down"
>> } }
>>
>> jshell> new int[100000]
>> $7 ==> int[100000] { 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