You don’t change the value of a (which is true by default) to false, you just call a method that will return false but nothing is set to this returned value.
Change your code to this:
package files;
public class EndLoopWithBooleanMethod {
static boolean a = true;
public static void main(String[] args){
while(a) { //This is enough as a is a boolean, the complete thing would be
//whlie (a == true)
EndLoop(a);
System.out.print(".");
EndLoop(a);
}
}
public static void EndLoop(boolean var){
var = false; //a is set to false instead of the method returning false
}
}
1
solved How to end while loop in Java