Jump to content
  • Advertisement
Sign in to follow this  

Question regarding nested ifs and conditional operator in Java

This topic is 5178 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys. I hope I am posting this in the right forum. I have a general question regarding the conditional operator in Java. I have the following if statement as an example:
if (a>b){
}else if (c<d){
}else if (b>d){
Is there a way I can do this using a single shorthand nested if with the conditional (?) operator? I have only seen the shortcut notation used in single if/else statements before and was just curious if it could be done with nested if's. I tried experimenting with it but I cant seem to get it to work. I appreciate any help you can give me. Thanks so much!!!

Share this post

Link to post
Share on other sites
Thanks for the reply Fruny! I tested it out and it works perfectly! Now that I look at how its done, I see that I was trying to make it a lot more complicated than it needed to be. Thanks again for the help!!!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!