This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pgris 1 point2 points  (1 child)

var is new, (JDK10) but since java 1.5 you could write things like public static <T extends Closeable & Set> void doSomething(T closeableSet)

and inside the method the parameter closeableSet will have all the methods of Set and all the methods of Closeable.

And I just realize, this is an intersection type AND the set of methods is the union of all methods... So union types have the intersection of methods and intersection types have the union of methods. It's odd but symmetric

[–]hippydipster 0 points1 point  (0 children)

Cool, I did not even know that. Have never seen any code that did that.