I have no idea of how to fix this, i am just a beginner
public static void main(String[]args){
int op;
Scanner teclado = new Scanner(System.in);
System.out.println("porfavor ingrese un numero entre 1 y 6: ");
op=teclado.nextInt();
if(op >=1 && <=6){
System.out.println("muchas gracias");
}else{
System.out.println("error,el numero debe estar entre 1 y 6");
}
}
}
将if(op >=1 && <=6)
更改为if(op >=1 && op<=6)
if(op >= 1 && op <= 6)
&&
is an infix operator that takes boolean
and boolean
and returns boolean
. <=
is an infix operator that takes Number
and Number
and returns boolean
. Your expression is missing an argument.
'&&'是一个逻辑运算符,适用于布尔逻辑,在这里您试图在运算符Ie(op(> = 1 && <= 6))上使用'&&',这在Java中是未定义的用法。其他语言U只需将其更改为(op> = 1 && op <= 6),就可以将其应用于两个单独的条件检查,这将返回布尔值,并且'&&'可以应用于
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.