PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, December 20, 2022

[FIXED] Why was the double colon operator chosen for Java 8?

 December 20, 2022     java, java-8, operators, syntax     No comments   

Issue

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

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>genericMethodName 

works 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.)



Answered By - gontard
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing