Take the following example:
private int[] list;
public Listing() {
// Why can't I do this?
list = {4, 5, 6, 7, 8};
// I have to do this:
int[] contents = {4, 5, 6, 7, 8};
list = contents;
}
Why can't I use shorthand initialization? The only way I can think of getting around this is making another array and setting list
to that array.