Monday, February 13, 2017

Learn Java for Beginner easily ! part 19 : Conditional Operators

     What's up Guys ! Welcome back in my Java tutorial series. First I want to say sorry guys because  I haven't been posting for a long time. Well , I'm kinda busy with college. Ok ! now in this quick tutorial I'm gonna show you guys how to use Conditional Operators. As usual, I want you guys to learn by examples because most people learn about something easier in that way. Enough with the chit chat, go write this codes below :



So.. I'm wondering that now you guys are wondering what is the Statement on Line 6 means. The explanation is right on the picture below.


 So, The statement above is like you tell Java that If  variable "size" value is less than 50, then Java must print "String 1" and if not, the Java must print "String 2" . So the syntax is first you're gonna have to write down the requirements then type question mark (?) right next to it.
If the requirements are required, then Java will print out the first string you've input on the left then if it's wrong then Java will print out the String on the right.Both of strings are separated with colon  ( : ) and remember, NOT a semicolon ( ; ).

In the case of codes above, the requirements are required. That's why Java print out the String 1 on the left, not the right one.

So that's it guys for now. Thank you guys for visiting my blog, hope you guys enjoy it and see you on the next tutorial. If you guys got something to be asked, please leave a comment below and thank you very much.

Greetings from Programmer !

No comments:

Post a Comment