'Why was the double colon operator chosen for Java 8? [duplicate]
Prior to Java 8, my observation was that the de facto standard for referring to member methods was by using the # symbol (such as Object#toString()). Then along came Java 8 which instead chose the :: operator for method references for seemingly no reason.
Has there been an official explanation or justification for why :: in particular was chosen?
Solution 1:[1]
You could find an "official explanation or justification" from Brian Goetz. You should read the complete discussion but this is an extract :
The :: infix syntax:
ClassName::methodName ClassName<T>::methodName ClassName::<U>genericMethodNameworks acceptably well. Some people like it, and some people hate it -- just like #. There's never going to be a perfect syntax for anything that makes everyone jump up in unison and say "yeah, that's it!" But :: is OK, and using up :: here is far better than using up #. (And, while this might look a little weird to C++ programmers, the overlap between the Java and C++ developer bases at this point is small enough that I don't think we should be too worried about that.)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
