In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Today, I will talk to you about how to use jShell to quickly achieve code prototyping, many people may not know much about it. In order to make you understand better, the editor summarizes the following contents. I hope you can get something according to this article.
Interpretive programming languages have been able to execute code quickly on the command line many years ago. You don't need to start IDE or compile, and you can type in the code to see the results immediately. This approach has proved to be very helpful to beginners. Because you try a new programming language like this, you won't be bothered by compilers, dependencies, and build systems. JShell is an often overlooked feature in JDK9: it is a Read-Evaluate-PrintLoop (REPL) environment where Java code can be called without compilation in JSHell.
What is REPL?
In short, just type a few commands (Read), it will be interpreted (Evalueate), and the result of the command will be forwarded (Print). This process continues until Loop. This is R (ead) E (valuate) P (rint) L (oop).
Start JShell
If the command line supports JavaJDK9 or later, simply type jshell to start JShell.
Call JShell
When the jshell > prompt appears, it indicates that JShell is currently in R (ead) mode, waiting for input.
To quickly browse the available commands, type / help
JShellhelp
Commands, code completion, and references
JShell uses the TAB key for code hints and automatic completion. Enter System.out, press TAB to complete the System.out.println ("HelloWorld"):
Code hints and automatic completion
In fact, REPL prints all the commands entered, so there is no need for System.out print commands
Variable and result reference
One of the interesting features of JShell is its support for forward references. Forward references refer to methods, variables, or classes that are not defined in JShell. For example, there is a valueOfStocks method that calculates the total value of stocks held based on the current price and the number of stocks you own. You can define the method of calculation before providing the actual quantity and current price of each stock.
Use external development libraries
JShell supports saving and importing resources (that is, JShell scripts) locally, using the / save and / open commands, respectively. You can also load previously saved sessions when JShell starts.
With JShell, you can easily test code snippets or prototype algorithms without compiling code. In the REPL environment, the commands entered can be fed back directly. For more information about JShell, you can refer to Oracle's JShell tutorial.
After reading the above, do you have any further understanding of how to use jShell to quickly implement code prototyping? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.