深圳网站建设公司小江,品牌建设规划,七七影视大全在线看免费,十大免费ppt网站软件jshell这篇文章建立在我的My Java 9顶级功能文章的基础上#xff0c;通过对这些功能的深入研究。 在这里#xff0c;我们向您展示如何在五分钟内学习jshell并改善Java 9开发经验。 入门 假设您已经下载并安装了Java 9#xff0c;则可以通过键入以下内容启动Shell#xff1… jshell 这篇文章建立在我的My Java 9顶级功能文章的基础上通过对这些功能的深入研究。 在这里我们向您展示如何在五分钟内学习jshell并改善Java 9开发经验。 入门 假设您已经下载并安装了Java 9则可以通过键入以下内容启动Shell jshell 或者如果您要详细- C:\jdk9TestGroundjshell -v
| Welcome to JShell -- Version 9
| For an introduction type: /help introjshell变数 只需键入变量带或不带分号– jshell int i 1;
i 1
| created variable i : int 未分配的值会自动分配给以$ –开头的变量 jshell Hello World
$1 Hello World
| created scratch variable $1 : String 这意味着我们以后可以重用该值– jshell System.out.println($1);
Hello World控制流程 jshell的下一步是使用控制流对于ifwhile…。 我们可以通过输入条件对每个新行使用return来做到这一点– jshell if (Hello World.equals($1)) {... System.out.println(Woohoo my if condition works);... }
Woohoo my if condition works 快速提示是使用TAB进行代码完成 方法 我们可以用与流程控制类似的方式声明一个方法然后按 每条新线– jshell String helloWorld() {... return hello world;... }
| created method helloWorld() 然后叫它– jshell System.out.println(helloWorld());
hello world 我们还可以更改外壳程序中的方法并使用方法调用尚未定义的方法- jshell String helloWorld() {... return forwardReferencing();... }
| modified method helloWorld(), however, it cannot be invoked until method forwardReferencing() is declared
| update overwrote method helloWorld() 现在我们修复方法– jshell String forwardReferencing() {... return forwardReferencing;... }
| created method forwardReferencing()
| update modified method helloWorld()班级 我们还可以在jshell中定义类– jshell class HelloWorld {... public String helloWorldClass() {... return helloWorldClass;... }... }
| created class HelloWorld 并分配和访问它们- /env有用的命令 现在我们已经掌握了一些基本的快速命令– 标签 代码完成 / vars 当前shell中的变量列表 /方法 当前shell中的方法列表 /清单 jshell会话中的所有代码段 /进口 当前在外壳进口 /方法 当前shell中的方法列表 /类型 当前的类在外壳中定义在上述情况下我们将看到“类HelloWorld” /编辑 使您可以在编辑器中编辑会话默认为JEditPad /出口 闭门会议 翻译自: https://www.javacodegeeks.com/2017/10/jshell-five-minutes.htmljshell