为什么带有赋值和等式检查的if语句的计算结果为false?
public static void test() {
boolean test1 = true;
if (test1 = false || test1 == false) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
Run Code Online (Sandbox Code Playgroud)
为什么要打印No?
为什么total_amount并且tax_amount在下面的println语句中将它们连接在一起而不是作为数字加在一起?
public class Test{
int total_amount,tax_amount;
public void cal(int total_amount,int tax_amount)
{
System.out.println("Total amount : "+total_amount+tax_amount);
}
public static void main(String[] args) {
new Test().cal(100, 20);
}
}
Output Total amount : 10020
Expected Total amount : 120
Run Code Online (Sandbox Code Playgroud)