I'm doing some spec work with array types, and noticed what's probably a bug in the printing of arrays by JShell:
jshell> int[][] arr = new int[3][1]
arr ==> int[][3] { int[1] { 0 }, int[1] { 0 }, int[1] { 0 } }
jshell> int[][] arr = new int[3][]
arr ==> int[][3] { null, null, null }
Looks like the format here is
<component-type>[<length>] { <components> }
However, as you can see in the initialization expressions, this gets the dimensions backwards compared to the way the language likes to treat them. I suggest a different, more complex format, that aligns better with the language's usage:
<element-type>[<length>]<extra-dims> { <components> }
This would look like:
jshell> int[][] arr = new int[3][1]
arr ==> int[3][] { int[1] { 0 }, int[1] { 0 }, int[1] { 0 } }
jshell> int[][] arr = new int[3][]
arr ==> int[3][] { null, null, null }
—Dan
jshell> int[][] arr = new int[3][1]
arr ==> int[][3] { int[1] { 0 }, int[1] { 0 }, int[1] { 0 } }
jshell> int[][] arr = new int[3][]
arr ==> int[][3] { null, null, null }
Looks like the format here is
<component-type>[<length>] { <components> }
However, as you can see in the initialization expressions, this gets the dimensions backwards compared to the way the language likes to treat them. I suggest a different, more complex format, that aligns better with the language's usage:
<element-type>[<length>]<extra-dims> { <components> }
This would look like:
jshell> int[][] arr = new int[3][1]
arr ==> int[3][] { int[1] { 0 }, int[1] { 0 }, int[1] { 0 } }
jshell> int[][] arr = new int[3][]
arr ==> int[3][] { null, null, null }
—Dan
- relates to
-
JDK-8166400 JShell: friendlier representation of array values
-
- Closed
-