nested-generics

Java: Nested generics?

Can Java nest generics? The following is giving me an error in Eclipse: ArrayList<ArrayList<Integer>> numSetSet = ArrayList<ArrayList<Integer>>(); The error is: Syntax error on token "(", Expression expected after this token ...

Generic Visibility of inner classes?

I have a code piece that looks something like what I've pasted below: import java.util.LinkedHashMap; import java.util.Map; public class GenericMagic { GenericMagic() { } private class Container { int doSomething(){ return 42;} @Override public String toString() { return "Container"+doSomething(); } } ...

Passing a reference to a TObjectDictionary<TKey, TValue>.TValueEnumerator

Hi All, I am trying to use Delphi 2010's TObjectDictionary generic. I would like to pass an enumerator of the Values property of that generic class, and the compiler doesn't seem to want to let me... Example: TAttributeStates = class(TInterfacedObject, IAttributeStates) private FStates: TObjectDictionary<TPatchAttribute, TAttr...

Generic tree, self bounded-generics

Hi, I am to adding genericity to one of my projects. I love generics as this makes my code more robust, self-documented and erases all those ugly casts. However, I came across a tough case and have some issues trying to express a "recursive" constraint for one of my structures. This is basically some kind of "generic" tree, with dou...

What do nested generics in C# mean ?

Hi, A bit of a basic question, but one that seems to stump me, nonetheless. Given a "nested generic": IEnumerable<KeyValuePair<TKey, TValue>> Is this stating that IEnumerable can have generic types that are themselves KeyValuePair 's ? Thanks, Scott ...

Please help me understand polymorphism when using generics in c#.

I am having a problem understanding how polymorphism works when using generics. As an example, I have defined the following program: public interface IMyInterface { void MyMethod(); } public class MyClass : IMyInterface { public void MyMethod() { } } public class MyContainer<T> where T : IMyInterface { public IList...