5.3 How to use Ternary Operator in Java Tutorial

preview_player
Показать описание
Suppose I declare two variable i=1,j=5 and if i==1 then print j=6 then I instead of using if else we use j=i==1?6:7.You can replace your if else with ternary. Ternary operator is to assign the minimum (or maximum) value of two variables to a third variable.

Follow on Facebook:

Subscribe to our other channel:
Telusko Hindi :

Subscribe to the channel and learn Programming in easy way.

Рекомендации по теме
Комментарии
Автор

low volume.. difficult to understand what you speak. :(

rslechu
Автор

Dude this saved my comp Class test, thanks bhai

ktara
Автор

Good One, all your explanation is from basic.

Smruti..-
Автор

sir i have a doubt, what condition have you taken to be true in if(true) condition plz explain

salmanabbas
Автор

awesome unknown fact, thank you so much navin sir

arunrajak.b
Автор

sir please show some theoretical explanation of the different concepts that are explained practically.

happyVibesOnly
Автор

sir can you explain in detail about this ternary operator. I really don't understand the last example.

nandishpatel
Автор

Currently using your videos to read code and figure out ways to create plugins for a custom programmed MC server I wanna make. Your videos are clear, short, and easy to understand. +1 like for each video and +1 sub for you. :)

________________
Автор

i used float instead of double then too it showed 10.0 as
dont they take same space.

AkashSingh-yprt
Автор

On compiling, I'm getting this message:
IfElseVSTernOp.java

Note: IfElseVSTernOp.java uses or overrides a deprecated API.

Note: Recompile with -Xlint:deprecation for details.


What is "-Xlint" ?

NikhilRaj-bhwc
Автор

Why don't you improve the sound quality? sometimes it feels like you are shouting and the next moment nothing is audible.

antarasaha
Автор

sir,
upto now u have not explained about object and u area suddenly using object

sanjaych
Автор

Could u able to run using user input and execute the condition acording to the user input

dpanjobs
Автор

can u explain what if it's multiple expression instead of single(?)
"var='(exp1)?(exp2):(exp3)".

avinod
Автор

sir ... the functioning of the ternary operatior is same as in dz above example for c programming I jst wanna plzzzz rply me sir

saidivyalakshmireddy
Автор

Sir, in this video, sound is not audible. And this problem is occuring in some of the other videos also.Kindly do the needful

thiagarajanselvaraj
Автор

class MyClass
{
public static void main(String args[])
{
{
int x = 5;
if (x < 1);
System.out.println("Hello");
}
}
}

in the program above the output is Hello. I don't understand why?

ashishmeshram
Автор

Is it necessary to write package com.navin ; in this coding

sid
Автор

and if value in the right is smaller then what ???
e.g .
true?new Integer(10):new Double(5.0);

in my case it also gives 10.0 although 5.0 is smaller than 10 but it is selecting the data type of minimume number i.e 5.0

asimshahzad
Автор

Hi, very nice explanation! Easy to understand! Can you make video regarding chained ternary operator - little more complex? Thank you. Keep on.

vladanulardzic