Question: Question:
It is a code rewritten to simplify the intention of the previous question. Since it is controlled using TimerTask, control statements such as break cannot be used. Why doesn't it end with setting L to false?
public class Main {
public static void main(String[] args) {
boolean K = true;
boolean L = true;
while(and(K,L)){
System.out.println("test");
L = false;
}
}
public static boolean and(boolean a, boolean b){
if(a = true){
if(b = true){
return true;
}
}
return false;
}
}
Answer: Answer:
If =
, it will be an assignment. It should work if you use the comparison operator ==
.
if(a == true){
or,
if(a){
It's fine just.