Click here to watch in Youtube :
https://www.youtube.com/watch?v=nc-mcdLEClw&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java Ternary Operator |
class TernaryOperatorDemo { public static void main(String[] args) { int value1 = 10; int value2 = 20; int result; boolean flag = true; /* * If flag is true, assign the value of value1 to result. * Otherwise, assign the value of value2 to result. */ result = flag ? value1 : value2; System.out.println("flag is true : " + result); flag = false; /* * If flag is true, assign the value of value1 to result. * Otherwise, assign the value of value2 to result. */ result = flag ? value1 : value2; System.out.println("flag is false : " + result); } }
flag is true : 10 flag is false : 20
https://sites.google.com/site/javaee4321/java/OperatorsDemoTernaryApp.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/OperatorsDemoTernaryApp
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/445777649bb0659322badeabdb5f7ba017537917/BasicJava/OperatorsDemoTernaryApp/?at=master
See also:
No comments:
Post a Comment