The only way you can do this check is if you have the Class
object representing the type:
Class<T> type; //maybe passed into the method
if ( type.isInstance(obj) ) {
//...
}
More Related Contents:
- Java: Instanceof and Generics
- Difference between
- Java Generics (Wildcards)
- Java generics super keyword
- Java Enum definition
- What does the question mark in Java generics’ type parameter mean? [duplicate]
- The performance impact of using instanceof in Java
- Why can’t a Generic Type Parameter have a lower bound in Java?
- Generic type parameter naming convention for Java (with multiple chars)?
- Implement converters for entities with Java Generics
- LambdaConversionException with generics: JVM bug?
- How to avoid ‘instanceof’ when implementing factory design pattern?
- Why does this generic code compile in java 8?
- How to create a class literal of a known type: Class
- Java nested generic type
- Is there something like instanceOf(Class c) in Java?
- Why shouldn’t Java enum literals be able to have generic type parameters?
- Java: Casting from List to List when B implements A?
- Iterate enum values using java generics
- How to sum values in a Map with a stream?
- Reflection for Class of generic parameter in Java?
- Why should I care that Java doesn’t have reified generics?
- Get type name for generic parameter of generic class [duplicate]
- instanceof Vs getClass( )
- Java: bounded wildcards or bounded type parameter?
- Generic class that accepts either of two types
- List is a raw type. References to generic type List should be parameterized
- incompatible types and fresh type-variable
- Storing different types of elements in a List in Java
- ArrayList Generic without Type