Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Method reference

Hello,

In the video Dennis shows as an alternate (albeit inferior solution) to use Method referencing on the .forEach Method which takes a consumer.

Why is it possible to use Method referencing in the .forEach(juniorJobs::add) part?

Isn't the requirement for method referencing that there is only one abtract method whose signature has to be matched (usually Class::Method)?

Here, juniorJobs is not a class but an instantiated variable and there is more than just one method available for this object.

Many thanks and kind regards, Toby