在Java中,你可以使用条件语句(if-else语句)来设定数值的范围。下面是一个示例:
```java
int number = 10;
if (number >= 0 && number <= 10) {
System.out.println("Number is between 0 and 10.");
} else if (number > 10 && number <= 20) {
System.out.println("Number is between 11 and 20.");
} else {
System.out.println("Number is outside the specified range.");
}
```
上述代码检查变量`number`是否在0到10之间,如果是,则打印"Number is between 0 and 10."。如果不在该范围内,程序会继续检查是否在11到20之间,如果是,则打印"Number is between 11 and 20."。如果不在任何范围内,则打印"Number is outside the specified range."。
你可以根据自己的需求修改范围条件。