int time=0;
int x=1;
int w=2;
int y=1;
int h=1;
int t=6;
while (x != w && y != h) {
boolean s = Abc (a,b,c,time);
if (s == true) {
time = time+t;
x++;
}
else if (s = false) {
time = time++;
}
}
System.out.println(time);
This is a part of program I'm writing for school and my problem is that when the program enters the while loop no matter what I do inside the loop when it exits and prints the variable "time" the value is the same as the value set at the beginning. Am I missing something? (BTW Abc is just a method that should return the value true when I first enter the loop, therefore the value of time should be changed to time+t)
else if (s == false)(even if it is a little too overkill)s = false->s == falseelse it will setsto false instead of comparing it, alsotime = time++does nothing. Usetime++insteadyandhare equal.if (s) { ... } else { ... };