我收到这个奇怪的错误:
Ex2.java:8: error: ';' expected
If (IMC <= 15.0){
^
Ex2.java:11: error: ';' expected
If (IMC <= 19.0)
^
Ex2.java:15: error: ';' expected
If (IMC <= 25.0)
^
Ex2.java:19: error: ';' expected
If (IMC <= 30.0)
^
Ex2.java:23: error: ';' expected
If (IMC <=40.0)
^
Ex2.java:27: error: ';' expected
If (IMC <=90.0)
我问了一些 friend ,他们不知道为什么会发生这种情况 在这里,拿走我的代码。
public class Ex2 {
public static void main(String[] args) {
double peso = 80;
double altura = 1.88;
double IMC = (peso / (altura * altura));
System.out.print("IMC:");
System.out.println(IMC);
If (IMC <= 15.0){
System.out.println ("Muito abaixo do peso ideal");
}
If (IMC <= 19.0)
{
System.out.println ("Abaixo do peso ideal");
}
If (IMC <= 25.0)
{
System.out.println ("Peso Normal");
}
If (IMC <= 30.0)
{
System.out.println ("Acima do peso ideal");
}
If (IMC <=40.0)
{
System.out.println ("Obeso");
}
If (IMC <=90.0)
{
System.out.println ("Muito Obeso");
}
}
}
最佳答案
Java 是高度区分大小写的,它是 if
而不是 If
关于java - ';'预计在 if 之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26280216/