在Java 9的JShell中使用变量

PHPz
PHPz 转载
2023-09-08 18:25:02 334浏览

在Java 9的JShell中使用变量

在 JShell 9 中,可以在会话期间声明变量。用户登录会话后,他们可以声明一个变量,如下所示 -

jshell> int val = 56 ;

Italics indicate the terminal, once the user has logged in to their session.

The above line would print the below output. The semicolon in the above line is optional, and it will run fine without the semicolon also.

输出

val = = > 56

当通过将整数值分配给 JShell 上的变量名称来定义该整数值并通过按“Enter”键执行该整数值时,它会显示在 JShell 命令行的下一行。

如果我们不将变量分配给值,而只是将其打印在 JShell 上,它会将变量分配给值 -

jshell> 79

输出

$3 = = > 79

当在 JShell 上定义一个整数值但未将其分配给变量名并执行时,按“Enter”键,它会显示在 JShell 命令行的下一行。在这里,JShell 本身为最近输入的变量值分配一个变量名称。

以上就是在Java 9的JShell中使用变量的详细内容,更多请关注php中文网其它相关文章!

声明:本文转载于:tutorialspoint,如有侵犯,请联系admin@php.cn删除