Home > Java > javaTutorial > body text

Using variables in JShell in Java 9

PHPz
Release: 2023-09-08 18:25:02
forward
1135 people have browsed it

在Java 9的JShell中使用变量

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

jshell> int val = 56 ;
Copy after login

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
Copy after login

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

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

jshell> 79
Copy after login

输出

$3 = = > 79
Copy after login

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

The above is the detailed content of Using variables in JShell in Java 9. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template