Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the name of the :: operator in Java 8

I can't find the name of the :: operator added in Java 8 in either of the following resources:

  • Proposed Final Draft Specification: The Java Language Specification (JLS)
  • JSR-000335 Lambda Expressions for the Java Programming Language Proposed Final Draft
like image 361
Sam Harwell Avatar asked Jan 22 '14 03:01

Sam Harwell


1 Answers

As per here, it looks like it's called a method reference operator. It's covered in section 15.13 of the proposed JLS you link to.

However, as rightly pointed out, it appears to be never explicitly named as an operator (unlike all the things like +, - and so on). Instead, the JLS simply refers to the entire expression containing :: as a method reference expression.

It may be that this is because :: is not considered to be an operator at all but is explicitly called out as a separator (see JLS link 3.11, while the operators are in 3.12).

So I would tend to call it, in the context you're interested in, a method reference separator (or, more generally, the double-colon separator).

like image 128
paxdiablo Avatar answered Oct 03 '22 11:10

paxdiablo