Home> Java> javaTutorial> body text

How to print a pattern of stars in JShell in Java 9?

PHPz
Release: 2023-08-30 18:13:02
forward
524 people have browsed it

如何在Java 9的JShell中打印星星的图案?

JShellis a REPL tool introduced in Java 9 that allows us to execute Java code and getting results immediately. We canevaluateexpressionsor 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 typingjshell. We can use different commands:/exitto quit the JShell session,reset/reloadJShell anytime by typing/reset, and /reload,/importto list the imports, etc.

In the below example, we canprint the starsin 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(""); ...> } * ** *** **** ***** ****** ******* ******** ********* **********
Copy after login

The above is the detailed content of How to print a pattern of stars 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!