
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
How to implement a lambda expression in JShell in Java 9?
JShell is a Java's first REPL and command-line tool that provides interactive use of Java programming language elements. We can test the functionality in isolation of a class by using this tool. JShell creates a simple and easy programming environment in the command-line that takes input from the user, reads it, and prints the result. A lambda expression is a function that has created without belonging to any class.
In the below example, we can implement a lambda expression in JShell.
C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> Consumer<String> s = (String s) -> System.out.println(s) s ==> $Lambda$14/1268066861@3159c4b8
If we can’t remember the method of Consumer interface then type the name of a variable created followed by a dot and press tab. It populates a list of methods that can be called on the Consumer interface.
jshell> s. accept( andThen( equals( getClass() hashCode() notify() notifyAll() toString() wait( jshell> s.accept("Welcome to Tutorialspoint") Welcome to Tutorialspoint
- Related Articles
- How to implement a String in JShell in Java 9?
- How to implement a Set interface in JShell in Java 9?
- How to implement java.time.LocalDate using JShell in Java 9?
- How to implement IntBinaryOperator using lambda expression in Java?
- How to implement ToIntBiFunction using lambda expression in Java?
- How to implement ToDoubleBiFunction using lambda expression in Java?
- How to implement ToLongFunction using lambda expression in Java?
- How to implement ToLongBiFunction using lambda expression in Java?
- How to implement DoubleToIntFunction using lambda expression in Java?
- How to implement DoubleToLongFunction using lambda expression in Java?
- How to implement DoubleFunction using lambda expression in Java?
- How to implement ToDoubleFunction using lambda expression in Java?
- How to implement DoubleConsumer using lambda expression in Java?
- How to implement PropertyChangeListener using lambda expression in Java?
- How to implement IntFunction with lambda expression in Java?

Advertisements