java - 我的 do 语句中的缩进出错
问题描述
所以我在do
声明的缩进方面遇到了麻烦。缩进是否会有所不同,因为我检查了所有内容,并且通过它看起来很好?
public void menu()
{
char option = '\0'; //This is intaillsing the character
Scanner scanner = new Scanner(System.in);
System.out.println("Welcome" + customerName);
System.out.println("\n");
//These will be all the option that will be dispalyed for the user to choose an option
System.out.println("A. Check Balance");
System.out.println("B. Deposit");
System.out.println("C. Withdraw");
System.out.println("D. Previous transaction");
System.out.println("E. Deposit using checks");
System.out.println("F. Exit");
do //This is saying to do all of these statement
{
System.out.println("Enter an option");
option = scanner.next().charAt(0);
System.out.println("\n");
switch(option)
{
case 'A':
System.out.println("Balance = " + balance);
}
}//This indentation is showing me error
}
解决方案
Java 在循环结构中没有语义上有意义的空白。您缺少循环结构的一半。特别while (condition);
是do-while
循环的。
do {
// ...
} while (condition);
推荐阅读
- python - 我该如何解决这个问题:没有名为“simple_history”的模块
- javascript - 如何使用观察者检查 div 是否可见?(也许是 Azure 服务器问题?)
- sql - spark sql中的广播连接左表
- php - php 避免在 openssl_encrypt 和 base64_encode 的输出中出现特殊字符
- java - 在Java中将字节数组转换为json字符串的最佳方法是什么?
- javascript - 试图让这个程序在下面工作,但当我使用 .lenght 时总是不确定
- java - 模拟休息模板返回空响应
- python - 如何在 Flask 中使用 Gunicorn
- d3.js - 缩放和居中 D3-Graphviz 图形
- amazon-web-services - Terraform 导入 aws 资源