Package modernfeatures.methodreferences
Class MethodReferenceExample
java.lang.Object
modernfeatures.methodreferences.MethodReferenceExample
Demonstrates the use of method references in Java, and contrasts them with lambda expressions.
Method references provide a concise way to refer to an existing method, making code more readable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Main method demonstrates printing each name in a list using both a lambda expression and various types of method references.void
printLower
(String stringName) static void
printUpper
(String stringName)
-
Constructor Details
-
MethodReferenceExample
public MethodReferenceExample()
-
-
Method Details
-
main
Main method demonstrates printing each name in a list using both a lambda expression and various types of method references. The output is identical, but the method reference syntax is more concise.- Parameters:
args
- Command-line arguments (not used)
-
printUpper
-
printLower
-