Skip to content
Advertisement

Tag: ampersand

Why is this lambda expression cast using an ampersand?

recently I stumbled over the following code in the Java Comparator class: What’s confusing me is the (Comparator<T> & Serializable) part. Since the method only returns a Comparator I don’t see the use in casting to Serializable. I also don’t see the reason to ever cast anything this way, or am I missing something? It seems to me that if

Advertisement