@Nullable Using Annotation

Asked 1 years ago, Updated 1 years ago, 121 views

void foo(@Nullable Object obj)
{ ... }

I saw this code. What does @Nullable mean here? Do you mean to put null in the parameter? @Even without Nullable, we can put null in the parameter, right? I don't know what you mean.

java annotations

2022-09-22 22:17

1 Answers

@Nullable is a clearer indication of whether the method accepts a null value. Writing code in this way helps you analyze in programs such as FindBugs, which generates a warning if you don't check if it's null at the beginning of the method.


2022-09-22 22:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.