Where to put @Nullable on methods with null return types?

When used javax.annotation.Nullableto designate methods as "potentially returning a value null", where to put the annotation @Nullable? About a method or return type?

Is there any technical difference, or is it strictly a style problem?

Style A:

@Nullable
public Object blah() { ... }

Style B:

public @Nullable Object blah() { ... }
+4
source share
2 answers

This is strictly a style issue.

, , . - - @Target javax.annotation.Nullable, javax.annotation.Nullable . , Java , public.

. , , . , .

: Nullable, . Java 8. , , . , Nullable, Eclipse Checker Framework, .

+7

. Option , None null.

-1

All Articles