Generics question

Hi every body,

In the following code

publicclass Test<T>{

publicvoid test(T t

t.execute()

}

}

i want to apply a method execute on the object t: I know that this method exists since T will only have 3 differents values in my application. How tell to the compiler than T will be T1, T2 or T3 all with the execute method.

Should i have to write a superT class and tells to my generics classe somethin like

publicclass Test<Textends superT>{

}

or have i to use an other solution and what is this solution ?

Thanks

Manu

PS: is it possible in C++ to write the same code

publicclass Test<T>{

publicvoid test(T t

t.execute()

}

}

without a compil error and only a runtime error ?

[1399 byte] By [Manu38100a] at [2007-10-2 20:20:01]
# 1
Well, in this case there's no reason for the method to be generic at all. It's simpler to simply saypublic void test(superT t) { t.execute(); }
malcolmmca at 2007-7-13 23:02:18 > top of Java-index,Java Essentials,Java Programming...
# 2
I am stupid!!!Thanks
Manu38100a at 2007-7-13 23:02:18 > top of Java-index,Java Essentials,Java Programming...