java - Java - 输出行
问题描述
我想知道是否有办法在运行后在输出中创建一行,
代码是
int topScore = 80;
if (topScore < 100) {
System.out.println("You got the high score!");
}
int secondTopScore = 60;
if (topScore > secondTopScore && topScore < 100) {
System.out.println("Greater than second top score and less than 100");
}
//Video 36 - Logical OR Operator
int topScore1 = 80;
if (topScore1 < 100) {
System.out.println("You got the high score!");
}
int secondTopScore1 = 81;
if ((topScore1 > secondTopScore1) && (topScore1 < 100)) {
System.out.println("Greater than second top score and less than 100");
}
输出是
You got the high score!
Greater than second top score and less than 100
You got the high score!
但是我希望它有一个空格链接这个
You got the high score!
Greater than second top score and less than 100
**Blank Line
You got the high score!
我试过 \n 但似乎没有用
解决方案
您可以添加\n
到字符串的开头
int topScore = 80;
if (topScore < 100) {
System.out.println("\nYou got the high score!");
}
int secondTopScore = 60;
if (topScore > secondTopScore && topScore < 100) {
System.out.println("Greater than second top score and less than 100");
}
//Video 36 - Logical OR Operator
int topScore1 = 80;
if (topScore1 < 100) {
System.out.println("\nYou got the high score!");
}
int secondTopScore1 = 81;
if ((topScore1 > secondTopScore1) && (topScore1 < 100)) {
System.out.println("Greater than second top score and less than 100");
}
推荐阅读
- jquery - AJAX 调用时变量丢失
- javascript - GoogleScript - setValues() - 连接数组内的数组元素
- arrays - 如何将数组中的数字与英文字母对应?
- laravel - Laravel-Package:如何解决发送电子邮件的合同类?
- javascript - 是否可以在 Konva.js 中测量当前的 FPS?
- javascript - 如何找到hcaptcha回调函数
- amazon-web-services - 自动启动 cloudformation 中创建的 DMS 复制任务
- python - Django如何从列表中删除发件人
- plotly - 有没有办法查看整个路径的痕迹?数据似乎只出现在两极
- javascript - Laravel - 根据选择选项显示数据库数据