Showing posts with label Conditional Operators. Show all posts
Showing posts with label Conditional Operators. Show all posts

Java Ternary Operators / Chapter -10/Operator & Assignments /



java ternary operator or conditional operator


In whole JAVA conditional operator is the only ternary operator.


How To Use It?
It is very simple to use.
First, it checks the condition, if the condition is true then it executes next statement after ? symbol .
If the condition is false then it executes statement after (colon) : the symbol.


Syntax with an example.

example 1.

int a=(10<20) ? 50 : 60;

System.out.println(a);

Output is 50

Java-Conditional Operators / Chapter -10/Operator & Assignments /

In whole JAVA this is the only  ternary operator .

How To Use It?
It is very simple to use.
First, it checks the condition, if the condition is true then it executes next statement after ? symbol .
If the condition is false then it executes statement after : symbol.

Syntax with an example.


example 1.

int a=(10<20) ? 50 : 60;

System.out.println(a);

Output is 50


Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com