i have this code:
public void main() throws InterruptedException, IOException {
boolean a = true;
if(a == true) {
methodTwo();
} else {
methodOne();
}
}
public void methodOne() throws InterruptedException, IOException {
System.out.println("Using method one!");
}
public void methodTwo() throws InterruptedException, IOException {
System.out.println("Using method two!");
}
but for some reason when I run the code methodOne() is still being executed after methodTwo() even though a is true
and if a is false methodTwo() is still being executed
the print statement in methodTwo() is executed before the print statement in methodOne() no matter if a is true or false
what i need it to do is if a is true, ONLY execute methodTwo() and vice versa
can anyone help?
Aucun commentaire:
Enregistrer un commentaire