gpt4 book ai didi

java - REPL流程在开发中的应用

转载 作者:行者123 更新时间:2023-12-01 09:01:26 25 4
gpt4 key购买 nike

现在我正在阅读Heroku的文档,我有一个关于如何在开发中使用REPL流程的问题。我遇到障碍的声明就是这个。

https://devcenter.heroku.com/articles/getting-started-with-java#start-a-one-off-dyno

“它还可以用于启动附加到本地终端的 REPL 进程,以便在应用程序环境或随应用程序部署的代码中进行实验”

我知道我们对如何在 stackoverflow 中应用 REPL 流程有几乎相同的问题,即 What's a REPL process and what can I use it for? 。但是,我无法理解答案,因为问题的语言是 Node.js ,不幸的是我不熟悉。那么,你能将答案翻译成使用其他词语的答案吗?我了解Java。所以,我希望你会使用与Java相关的术语。

谢谢。

最佳答案

Java 还没有发布 REPL,在 Java 9+ 中它将是 JShell 。 REPL 是 Read、Evaluate、Print、Loop 的缩写,是解释性语言的标志(Java 是编译型语言)。但是,REPL 非常有用,他们添加了一个。

efrisch@eeyore ~ $ jshell
| Welcome to JShell -- Version 9-ea
| For an introduction type: /help intro


jshell> /help intro
|
| intro
|
| The jshell tool allows you to execute Java code, getting immediate results.
| You can enter a Java definition (variable, method, class, etc), like: int x = 8
| or a Java expression, like: x + x
| or a Java statement or import.
| These little chunks of Java code are called 'snippets'.
|
| There are also jshell commands that allow you to understand and
| control what you are doing, like: /list
|
| For a list of commands: /help

jshell> for (int i = 0; i < 4; i++) {
...> System.out.println(i);
...> }

0
1
2
3

关于java - REPL流程在开发中的应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41633171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com