@ NotNull @ NonNull how to use

clipboard.png

for example, how to use these two notes (do not distinguish the difference between the two for the time being)

I thought (method) added these two comments, then the return value of this method cannot be null, the editor will give the corresponding prompt that the compilation failed (like kotlin), but the result is not what I thought.
is actually exactly the same as adding or not. May I ask how to use these two annotations

?
May.06,2022

@ NotEmpty for collection classes
@ NotBlank for String
@ NotNull for basic types


Bean
@NotNull
private String name;
controller
@Valid Bean bean,BindingResult result
nameresult


Bean
public Bean(@NonNull Integer id) {
    this.id=id;
}
new Bean(null);
Menu