Two-dimensional non-null array of nullable elements

Viewed 279

In Java 8, where should I place the @Nullable/@NonNull type annotations in order to declare a two-dimensional non-null array of nullable elements?

When declaring a type (as in method signature), both

@Nullable Object @NonNull[][]

and

@Nullable Object @NonNull[]@NonNull[]

are syntactically valid.

Likewise, when defining a value (a zero-length array), I can use either

new @Nullable Object @NonNull[0][]

or

new @Nullable Object @NonNull[0]@NonNull[]

Which version is correct?

1 Answers
Related