T
Thomas G. Marshall
Given the following code, I've nested generics in a common way.
SimpleClass<ArrayList<String>>
Is there a limit to the nesting of such structures? a OF b OF c OF d
(repeat as needed)
I'm looking for it in the spec, and I 1. am crummy at looking for things in
the spec, and 2. cannot find it.
Thanks,
Thomas
<code>
public class Simple2
{
interface SimpleInterface<E>
{
void set(E x);
E get();
}
// Tried it with F...
static class SimpleClass<F> implements SimpleInterface<F>
{
F thing;
public void set(F x)
{
thing = x;
}
public F get()
{
return thing;
}
}
public static void main(String[] args)
{
{
SimpleClass<String> simple = new SimpleClass<String>();
simple.set("hello");
System.out.println(simple.get());
}
{
// Tried simpleclass OF arraylist OF string
SimpleClass<ArrayList<String>> simple
= new SimpleClass<ArrayList<String>>();
ArrayList<String> al = new ArrayList<String>();
al.add("hello");
al.add("there");
al.add("again");
simple.set(al);
System.out.println(simple.get());
}
{
// Tried simpleclass OF arraylist OF Integer
SimpleClass<ArrayList<Integer>> simple
= new SimpleClass<ArrayList<Integer>>();
ArrayList<Integer> al = new ArrayList<Integer>();
al.add(new Integer(5));
al.add(new Integer(6));
al.add(new Integer(7));
simple.set(al);
System.out.println(simple.get());
}
}
}
</code>
SimpleClass<ArrayList<String>>
Is there a limit to the nesting of such structures? a OF b OF c OF d
(repeat as needed)
I'm looking for it in the spec, and I 1. am crummy at looking for things in
the spec, and 2. cannot find it.
Thanks,
Thomas
<code>
public class Simple2
{
interface SimpleInterface<E>
{
void set(E x);
E get();
}
// Tried it with F...
static class SimpleClass<F> implements SimpleInterface<F>
{
F thing;
public void set(F x)
{
thing = x;
}
public F get()
{
return thing;
}
}
public static void main(String[] args)
{
{
SimpleClass<String> simple = new SimpleClass<String>();
simple.set("hello");
System.out.println(simple.get());
}
{
// Tried simpleclass OF arraylist OF string
SimpleClass<ArrayList<String>> simple
= new SimpleClass<ArrayList<String>>();
ArrayList<String> al = new ArrayList<String>();
al.add("hello");
al.add("there");
al.add("again");
simple.set(al);
System.out.println(simple.get());
}
{
// Tried simpleclass OF arraylist OF Integer
SimpleClass<ArrayList<Integer>> simple
= new SimpleClass<ArrayList<Integer>>();
ArrayList<Integer> al = new ArrayList<Integer>();
al.add(new Integer(5));
al.add(new Integer(6));
al.add(new Integer(7));
simple.set(al);
System.out.println(simple.get());
}
}
}
</code>