x=4 y=5 z=8
(x
public static void main(String[] args) {
int x=4,y=5,z=8;
boolean result = (x<y)&&(y<z);
if(result == true)
System.out.println("表达式结果为真");
else
System.out.println("表达式结果为假");
}
、<、&&都是逻辑表达式,结果只能是0或1,也就是false或true
因为a=4,b=5,所以a<b成立,结果为true
因为b=5,c=8,所以b<c成立,结果也为true
对于逻辑与&&,必须两侧表达式都成立,整个表达式才成立。由于两侧都是true,所以整个逻辑与表达式结果为真
public static void main(String[] args) {
int x=4,y=5,z=8;
boolean result;
result= (x<y)&&(y<z);
System.out.println(result);
}
x<y 是 1
y<z 是 1
1 && 1 是 1