我有一个要求的练习:
如果来自用户的输入等于我数组中的int(生成 用户每次都赢取随机数)。
我已经试过了:
Scanner attack = new scanner(system.in);
System.out.println("enter number");
String Attack = attack.nextLine();
Int number = Interger.parseInt(Attack);
//the error lies here
For(int i = number; DragonArray != i ; number++){}
我需要有关如何遍历生成数字的数组的帮助,以查看用户输入是否等于数组中的任何数字
If I understood correctly, the type of the
DragonArray
is array and i has type as integer. The error here is pretty clear. SinceDragonArray != i
has two different types, it will throw compile time error. The boolean operators can be used to compare same types only. Both the variables here should be of typeint
.