简体   繁体   中英

Using Nullness annotation with array

Can someone help me to understand the difference between the following three annotated return value methods ie how does the constraints on the return type of each differ from each other :

static @Nullable double[] multiply(){...}

static @Nullable double @Nullable[] multiply(){...}

static double @Nullable[] multiply(){...}

Type annotations are written immediately before the type to which they apply.

  • Double [] : An array of Double.
  • Double @Nullable [] : A nullable array of Double.
  • @Nullable Double [] : An array of nullable Double.
  • @Nullable Double @Nullable [] : A nullable array of nullable Double.

This is explained in the Java Language Specification, section 9.7.4 and in the Java Type Annotations Specification, section 2.2.1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM