這段代碼哪錯(cuò)了
public class HelloWorld {
? ? public static void main(String[] args) {
int one = 20 ;
? ?if((one %= 2) = 0);
? ? ? System.out.println("one是偶數(shù)");
? ??
? ??
? ??
? ??
}
}
public class HelloWorld {
? ? public static void main(String[] args) {
int one = 20 ;
? ?if((one %= 2) = 0);
? ? ? System.out.println("one是偶數(shù)");
? ??
? ??
? ??
? ??
}
}
2017-06-05
舉報(bào)
2017-06-05
public class HelloWorld {
??? public static void main(String[] args) {
int one = 20 ;
?? if(one % 2==0){
?? ??? System.out.println("one是偶數(shù)");
?? }
??? }?? ?
}
2017-06-05
"="是賦值運(yùn)算符,"=="是邏輯運(yùn)算
2017-06-05
賦值運(yùn)算符==是等于,=也可以賦值,比如變量one=5,不就表示把5賦值給變量one嗎?==和=有什么區(qū)別嗎?謝謝!