在if语句中什么条件是错误的

时间:2018-03-24 19:58:21

标签: java debugging if-statement

我会告诉你我要问的内容,这与此类似:Detect which condition is false in multiple if statement

让我们说我有这个if语句:

html {
  height: 100%;
  background: gray;
}

body {
  height: 100%;
  margin: 0;
  padding: 0;
}

#map-canvas {
  height: 100%;
}

#iw_container .iw_title {
  font-size: 16px;
  font-weight: bold;
}

.iw_content {
  padding: 15px 15px 15px 0;
}

如何检查哪个条件是错误的,哪个是真的? 与e.printStackTrace();

类似

1 个答案:

答案 0 :(得分:1)

理想的选择是使用调试器来评估每个语句。 但是,如果要打印结果,可以将每个检查提取到自己的变量中,然后打印结果:

boolean firstCheck = 1 > 2;
boolean secondCheck = 2 < 3;
boolean thirdCheck = "hello".equals("Hello");

System.out.println("First check is: " + firstCheck);
System.out.println("Second check is: " + secondCheck);
System.out.println("Third check is: " + thirdCheck);

if (firstCheck && secondCheck && thirdCheck) {
    //Do something
}
相关问题