Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • It's Object, essentially. There's no other common supertype between A and B. Commented Jul 13, 2021 at 8:54
  • Perhaps you are looking for an explanation of IntersectionType? Commented Jul 13, 2021 at 8:56
  • 1
    See also stackoverflow.com/questions/60148411/… Commented Jul 13, 2021 at 8:58
  • 3
    @FedericoklezCulloca It's not a syntax error. The type A & B is an intersection type that also happens to be a functional "interface" because A and B's foo-method has the same signature. The System.out.println will just print the toString of the lambda-object that is created. Commented Jul 13, 2021 at 9:00
  • 1
    @marstran didn't know that. Thanks for clarifying. Commented Jul 13, 2021 at 9:05