Created
July 26, 2017 11:19
-
-
Save RaynZayd/302c9e74af755eca8519189706b03ef7 to your computer and use it in GitHub Desktop.
/*This program tests if the condition is true and does something , otherwise do something else. It demonstrates the use of the short-hand ternary for conditions "?:" By Rayn Zayd */
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This program tests if the condition is true and does something , otherwise do something else. It demonstrates the use of the short-hand ternary for conditions "?:" | |
By Rayn Zayd | |
*/ | |
public class TestCondition{ | |
public static void main(String[] args){ | |
int value1 = 5; | |
int value2 = 10; | |
int result; | |
boolean thisCondition = false;//compiles when set to true and prints 5 | |
result = thisCondition ? value1 : value2; | |
System.out.println(result);// prints 10 because "thisCondition" is false. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment