This is impossible, and I almost do not see any value in it. You use generics to limit the type, for example. in collections. With the help of the operator, oryou know as much about the type as you know about the most specific supertype of both of them, Objectin this case. So why not just use it Object?
:
List<E extends String or Number> list =
list.get(0)? String Number? . String, Number - ... Object.
. :
<Integer or Float>
:
<Number>
? , Number , floatValue() intValue(). ?
, and:
<E extends Serializable & Closeable>
- E, Serializable, Closeable. , E Serializable, Closeable. . : Java Generics .