I currently have an if-statement like this:
if (test == null || testStr.equals("testStr")) {
//Do stuff here
//Small things happened here
//More stuff
if (test == null) {
System.out.println("Thank");
} else {
System.out.println("You");
}
}
So the basic idea is that the if statement happens when either of the conditions is true (In my case, both statement cannot be true at the same time).
However, once inside the if statement, there is a point where if the first condition is true, print "Thank". If the second condition is true, print "you". A lot of common statements are executed before we reach this diverging point.
Is this the best/simplest way of writing this whole if statement?
Thanks.
Aucun commentaire:
Enregistrer un commentaire