利用Math.abs()绝对值来判断试试。
如有帮助,望点击我回答右上角【采纳】支持一下。
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
double a=sc.nextDouble();
double b=sc.nextDouble();
if(Math.abs(a)<5 && Math.abs(b)<2.5){
System.out.println("In·the rectangle");
}else{
System.out.println("Not in·the rectangle");
}
}