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

Multiple conditional if() statements in Java?

$
0
0

I know this is going to seem like an unforgiveable sin, but I have 150 variables, and I want to create an if function that does the following:

if(a != 0 && b != 0 && c != 0....) {  //do this} else {  //do this instead}

However, when I set one of the if statement conditions (i.e b!=1), whilst the others are still the same (a!=0, c!=0), the else function is still run, even though it should be the initial //do this instead of the //do this instead (see code snippet above).

My question is:

1. Is there a reason why it is not working, and if there is, how do i fix it?
2. Is there a simpler way to do that without having to list all 150 variables !=0 && !=0etc..?

Cheers


Viewing all articles
Browse latest Browse all 6

Trending Articles



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