jmasterx
jmasterx

Reputation: 54133

Conditional templates in Java?

In C# I can do this:

public class QuadTree<T> where T : IHasRect

Is there a way to do something similar in Java?

Upvotes: 0

Views: 212

Answers (1)

JB Nizet
JB Nizet

Reputation: 691903

If where T : IHasRect means that T is a type that must implement the IHasRect interface, the Java equivalent is

public class QuadTree<T extends HasRect>

Read the generics tutorial for more information.

Upvotes: 11

Related Questions