JShell is a REPL tool introduced in Java 9 that allows us to execute Java code and getting results immediately. We can evaluate expressions or simple algorithms without creating a new project, compile or build it by using JShell. We can also execute expressions, use imports, define classes, methods, and variables. It is a part of Java 9 JDK but not JRE.
We can start JShell session in command-prompt by simply typing jshell. We can use different commands: /exit to quit the JShell session, reset/reload JShell anytime by typing /reset, and /reload, /import to list the imports, etc.
In the below example, we can print the stars in JShell by using the "for" loop.
C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> for(int i=0; i<10; i++) { ...> for(int j=0; j<=i; j++) ...> System.out.print("*"); ...> System.out.println(""); ...> } * ** *** **** ***** ****** ******* ******** ********* **********
以上就是如何在Java 9的JShell中打印星星的图案?的详细内容,更多请关注编程之家其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。