I have an example generic method. How to execute class keyword on generic type T like below?
import java.util.Arrays;
public class BaseTag {
public <T> T getW() {
String[] arr = {"A", "B", "C"};
return Arrays.stream(arr)
// .filter(arg -> T.class.isAssignableFrom(arg.getClass())) // another example
.map(T.class::cast)
.findFirst()
.orElse(null);
}
}