EN
Java - @Nullable annotation in generic method result
5 points
In this short article, we would like to show how to use @Nullable
annotation for generic method result in Java.
Quick solution:
xxxxxxxxxx
1
package com.dirask.example;
2
3
import javax.annotation.Nullable;
4
5
public class ClassName {
6
7
// Annotation should be placed before <T>.
8
// |||
9
// vvvvvvvvv
10
public <T> T methodName(/* Some arguments here ... */) {
11
//
12
// Some source code here ...
13
//
14
}
15
}