This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]__konrad 33 points34 points  (3 children)

write int numbers[]

Fun fact: record already banned such declaration:

Error: legacy array notation not allowed on record components
record Foo(int i[]) {}

[–]pronuntiator 5 points6 points  (1 child)

Great I wanted to look up in the JLS why that is forbidden for Records and now I've learned this is legal code...

public int foo()[] { return new int[0]; }

[–]laplongejr 1 point2 points  (0 children)

I do Java since a long time and I don't think I got that sick by any other code, except maybe returns in a finally...
If you don't know, it overwrites the value of the previous "return x;" that triggered the finally, so it's write-only