Instantiating generic class in java?
Question
I am using Java1.7 and using generics.
I wrote a generic class as below.
public class SomeCollection<T extends MyPojo<K>, K> {
}
Now, how can i instantiate above class? I mean how can i create an instance for above class?
I am doing as: SomeCollection<MyPojoSubClass, SomeType> sss = new SomeCollection<>();
Compiler is not giving any error. IS it correct way ?
Thanks!
Solution
new SomeCollection<MyPojo<String>, String>();
Or are we missing something?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow