Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java multi-"where" keyword?

How can I limit 2 generic types in a class definition? How should I "where T : " 2 times? I have 2 interfaces Simplex and Complex, and I want a class like

public class MyClass<T,S> where T: Simplex, where S: Complex
{
...
}

? or am I doing it wrong? Where can I find this documentation? googling for "java keyword where generics" doesnt really help: where is a very common word... I cant find it in the java trail on generics either...

like image 582
propaganda Avatar asked Dec 04 '22 18:12

propaganda


1 Answers

I believe this is the syntax you're looking for:

public class MyClass<T extends Simplex, S extends Complex> { }

See this Java Tutorials page for more information.

like image 146
Paul Bellora Avatar answered Dec 07 '22 09:12

Paul Bellora