所以我在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
}
答案 0 :(得分:4)
Java在循环结构中没有语义上有意义的空白。您缺少了一半的循环结构。特别是while (condition);
循环的do-while
。
do {
// ...
} while (condition);