Is it possible to have a variable amount of Element types in a java generic class -


i wondering if possible have this:

public class foo<t...> 

so can call class like

foo<object0> foo<object0, object1> foo<object0, object1, object2> 

with object 0, 1 , 2 different types, integer, float, string , on. possible, or have write class each lenght of generic types? if possible, how handle different types?

no, can't have that. best can public class foo<t extends someclassorinterface>. in example integer , float can define public class foo<t extends number>.

you can specify t must implement more 1 interface.

the syntax public class foo<t extends someinterface1 & someinterface2> valid, & meaning and.

unfortunately syntax public class foo<t extends someinterface1 | someinterface2> | meaning or not possible.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -