### Question:
Reflection { public static Type variableType(ParameterizedType type, TypeVariable<?> variable) { Class<?> clazz = (Class<?>)type.getRawType(); TypeVariable<?>[] typeParameters = clazz.getTypeParameters(); String name = variable.getName(); int index = 0; for (TypeVariable<?> candidate : typeParameters) { if (candidate.getName().equals(name)) { return type.getActualTypeArguments()[index]; } index++; } return null; } private  Reflection(); static Type resultType(Type declaringType, Type type); static Type variableType(ParameterizedType type, TypeVariable<?> variable); static Class<?> getClass(Type type); static boolean isGetter(Method method); static boolean isListIndex(Method method);  }### Answer:
@Test public void variableType() throws Exception { Method method = Foo.class.getMethod("put", Object.class, Object.class); assertEquals(String.class, Reflection.variableType( (ParameterizedType) Foo.class.getGenericSuperclass(), (TypeVariable<?>) method.getGenericParameterTypes()[0])); assertEquals(Integer.class, Reflection.variableType( (ParameterizedType) Foo.class.getGenericSuperclass(), (TypeVariable<?>) method.getGenericParameterTypes()[1])); }