我试图找出是否可以打印出一个int ONLY,如果它是一个数字数组中的值.例如:
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.");
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不确定的是你将在"if"之后放在括号中,以便系统打印"它在数组中"只有j在1和9之间.
谢谢!