Scope resolution operator is commonly used in C++ , but none of us ever thought of using scope resolution operator in java . Here come Java 8 with options unthought Ideas being implemented. Method reference in Java 8 is the ability to use a method as an argument for a matching functional interface. :: (double colon) is the operator used for method reference in Java. An interface with only one method is called a functional interface. For example, Comparable, Runnable, AutoCloseable are some functional interfaces in Java.
Its there all through the Internet saying Java does not have the scope resolution operator (::), in comparison with C++. Its on the way and it will be here with Java 8. Between Java and C++, only the operator :: (double colon) is same, the way it is implemented is different. So we cannot call it as scope resolution operator in Java. It is used for method referencing and not for scope resolution.Method reference using :: is a convenience operator. Method reference is one of the features belonging to Java Lamda Expressions. Method reference can be expressed using the usual lambda expression syntax format using –>In order to make it more simple :: operator can be used.
Syntax: <classname or instancename>::<methodname>
No comments:
Post a Comment