I'm coming from a JavaScript background and I'm seeing the ::
operator for the first time. I understand what it does, but I'm wondering why it's necessary. In JavaScript, something like this is perfectly valid:
[1, 2, 3].forEach(console.log);
There's no need for a new operator - I'm just not calling the log
function directly/explicitly. So my question is, why doesn't that work in Java? What is there in Java that makes the Class.method
unusable (masks it?!)?