

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to implement the Fibonacci series in JShell in Java 9?
JShell is a java shell tool introduced in Java 9 that allows us to execute Java code and prints the result immediately. It is a REPL (Read-Evaluate-Print-Loop) tool that runs from the command-line prompt.
A number is said to be the Fibonacci series if each subsequent number is the sum of the previous two numbers.
In the below example, we can able to implement the Fibonacci Series in the JShell tool.
C:\Users\User\>jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> int x=0, y=1, z=0, count=5; x ==> 0 y ==> 1 z ==> 0 count ==> 5 jshell> { ...> System.out.println(x+"\n"+y); ...> for(int i=0; i<count; i++) { ...> x=y; y=z; ...> z = x+y; ...> System.out.println(z); ...> } ...> } 0 1 1 2 3 5 8 jshell>
- Related Questions & Answers
- How to implement java.time.LocalDate using JShell in Java 9?
- How to implement JShell using JavaFX in Java 9?
- How to implement the encapsulation concept in JShell in Java 9?
- How to implement a String in JShell in Java 9?
- How to implement an ArrayList using JShell in Java 9?
- How to implement a lambda expression in JShell in Java 9?
- How to implement integer type conversion in JShell in Java 9?
- How to implement a Set interface in JShell in Java 9?
- How to implement the Fibonacci series using lambda expression in Java?
- How to implement relational and logical operators in JShell in Java 9?
- How to implement String utility and immutability in JShell in Java 9?
- How to implement HashMap, LinkedHashMap, and TreeMap in JShell in Java 9?
- How can we implement a map in JShell in Java 9?
- JShell in Java 9?
- How to debug JShell in Java 9?
Advertisements