Quantcast
Channel: Multiple conditional if() statements in Java? - Stack Overflow
Viewing all articles
Browse latest Browse all 6

Answer by Ocracoke for Multiple conditional if() statements in Java?

$
0
0

Surely it would be simpler to do something like this:

List<Integer> values = new ArrayList<Integer>();values.add(val1);values.add(val2);// And so forth...boolean pass = true;for (Integer v : values) {    if (v != 0) {        pass = false;        // You could log which variable failed here...    }}if (pass) {    // Do something} else {    // Do something else}

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>