首页 > Java > java教程 > 正文

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

PHPz
发布: 2023-08-30 18:13:02
转载
691人浏览过

如何在java 9的jshell中打印星星的图案?

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.

阶跃星辰开放平台
阶跃星辰开放平台

阶跃星辰旗下开放平台,提供文本大模型、多模态大模型、繁星计划

阶跃星辰开放平台 0
查看详情 阶跃星辰开放平台

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("");
...>    }

<strong>*
**
***
****
*****
******
*******
********
*********
**********</strong>
登录后复制

以上就是如何在Java 9的JShell中打印星星的图案?的详细内容,更多请关注php中文网其它相关文章!

相关标签:
全能打印神器
全能打印神器

全能打印神器是一款非常好用的打印软件,可以在电脑、手机、平板电脑等设备上使用。支持无线打印和云打印,操作非常简单,使用起来也非常方便,有需要的小伙伴快来保存下载体验吧!

下载
来源:tutorialspoint网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门推荐
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号