Is there any way by which we can create specific instance of generic type at runtime?
For example.
Cacheable instance = getCacheable(someInput);
getCacheble method will return me the instance of Cacheable. So it can be any class implementing Cacheable.for e.g. Customer,Product etc.Now I want to create a list of specific type returned by getCacheable as below.Is that possible? If yes how to do that?
List<? extends Cacheable> cacheList = new ArrayList<>();
I want to create ArrayList<Product> or ArrayList<Customer> based on the instance returned by getCacheable method.