int[][] b = new int[3][0]int[] c = new int[3] b[0] = c
does this compile / runtime?Commit: 33c97751 - add some eprog cards
Author: obrhubr <obrhubr@gmail.com>
Date: 2026-01-24T21:43:05+01:00
Changes: 3 note(s) changed (3 added, 0 modified, 0 deleted)
J)-A!rQ/Od
Note did not exist
int[][] b = new int[3][0]int[] c = new int[3] b[0] = c
does this compile / runtime?int[][] b = new int[3][0]int[] c = new int[3] b[0] = c
does this compile / runtime?| Field | Before | After |
|---|---|---|
| Front | <code>int[][] b = new int[3][0]</code><br><code>int[] c = new int[3]</code> <br> <code>b[0] = c<br></code> does this compile / runtime? | |
| Back | Yes, it works fine as we just set the pointer of b[0] to c. Java does not typecheck array dimensions. |
p1.Wet4$5I
Note did not exist
| Field | Before | After |
|---|---|---|
| Text | If we see "((C) D).something()" as a cast we can assume that {{c1::D is a subtype of C}}. | |
| Extra | This is relevant for EProg theory exercises in which we have to reconstruct a class hierarchy. |
tja~6C@vsv
Note did not exist
int[][] b = new int[3][0] int[] c = new int[3] b[0] = c
is fine| Field | Before | After |
|---|---|---|
| Front | Does Java enforce array dimensions using type- or runtime-checks? | |
| Back | No.<br><br><code>int[][] b = new int[3][0]</code> <br><code>int[] c = new int[3]</code> <br> <code>b[0] = c<br><br></code> is fine |