Quantcast
Channel: Is it correct to use multiple OR conditions in one if statement, what are alternatives? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Is it correct to use multiple OR conditions in one if statement, what are alternatives?

$
0
0

I would like to know which way is more suitable and efficient in achieving something like: checking if text was entered in a field

if(text1.equals("") || text2.equals("") || text3.equals("") || text4.equals("")) {  //Do Stuff}

I can see how this gets messy quickly with more than 2 fields, and would like to know if this is a correct way to do this, or do alternatives exist?


Viewing all articles
Browse latest Browse all 3

Trending Articles





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