【发布时间】:2015-10-16 20:19:31
【问题描述】:
我试图弄清楚是否只有当它是数字数组中的值时才可以打印出 int。 例如:
import java.util.Random;
public class arrays {
Random random = new Random();
public void method () {
int[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9};
int j = random.nextInt(20);
if() {
System.out.println("It is in the array.");
} else {
System.out.println("It is not in the array.");
}
}
}
我不确定的是,只有当 j 介于 1 和 9 之间时,您才会在“if”之后的括号中放入什么内容,以便系统打印“它在数组中”。
谢谢!
【问题讨论】: