Java中,Syntax error on token "else",是怎么一回事?

public class New {public static void main(String[] args) { int price = -5; int amount = -10; if (price > 0 && amount > 0);{ int totalCost = price * amount ; System.out.println(totalCost); }else{ System.out.println("price和amount的值都必须大于尀"0尀",否则无法计算");
2026年09月28日 16:10
有1个网友回答
网友(1):

  1. if  后面 只能对应一个else ,不能对应两个

  2. 可以 使用  if.....  else  if   .......   else 模式

  3. " if (price > 0 && amount > 0);{   "   中,把“;”删掉。

  4. 非法的标点符号导致语法错误,请删除这个标点符号

  5. if (A==a||A==b||B==a||B==b);{; 去掉