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

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

$
0
0

With an array and a loop and a boolean. Review your arrays... chances are... your teacher wouldn't have you create 150 integer variables.

int[] integers = new int[150];integers[0] = 1; // Set your like 150 variables like thisintegers[1] = 2; boolean isAllNotZero = false;for(int i = 0; i < integers.length - 1; i++) {   if(integers[i] != 0) {     boolean isAllNotZero = true;   }}if(isAllNotZero) {  // 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>