一、封装代码:
public static boolean rangeInDefined(int current, int min, int max) {
return Math.max(min, current) == Math.min(current, max);
}
二、测试类:
public static void main(String[] args) {
int current = 50;
if (rangeInDefined(current, 1, 10)) {
System.out.println(current + "再1-10之间");
}else {
System.out.println("不再");
}
}
三、返回结果:

本文介绍了一个简单的Java方法,用于判断一个整数是否位于指定的最小值和最大值之间。通过一个具体的示例展示了如何使用该方法,并给出了运行结果。
1140

被折叠的 条评论
为什么被折叠?



