#14 Ternary Operator in Java

  Рет қаралды 114,513

Telusko

Telusko

Жыл бұрын

Check out our courses:
Spring and Microservices Weekend Live Batch : bit.ly/spring-live-weekend
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : bit.ly/java-spring-cloud
Udemy Courses:
Java:- bit.ly/JavaUdemyTelusko
Spring:- bit.ly/SpringUdemyTelusko
Java For Programmers:- bit.ly/javaProgrammers
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusko.com/
In this lecture we are discussing:
1)What is ternary operator?
2)Why do we need ternary operator?
3)Syntax of ternary operator
4)example of ternary operator
#1
-- ternary operator is shorthand of if-else statement.
#2
why we need ternary operator?
a) to reduce the code
b) to make the code more readable
c) to make the code more compact
#3
Syntax:
variable = (condition)?value1 if condition is true :value2 if condition is false
boolean result =(5 less then 6)? true :false; //result false
#4
example:
in if-else we can check a given number is even or odd now we code this problem by
ternary operator.
int num=13;
String str=(num%2==0)?"Even":"Odd";
System.out.println(str); //output: Odd
Github repo : github.com/navinreddy20/Javac...
Java:- bit.ly/JavaUdemyTelusko
Spring:- bit.ly/SpringUdemyTelusko
More Learning :
Java :- bit.ly/3x6rr0N
Python :- bit.ly/3GRc7JX
Django :- bit.ly/3MmoJK6
JavaScript :- bit.ly/3tiAlHo
Node JS :- bit.ly/3GT4liq
Rest Api :-bit.ly/3MjhZwt
Servlet :- bit.ly/3Q7eA7k
Spring Framework :- bit.ly/3xi7buh
Design Patterns in Java :- bit.ly/3MocXiq
Docker :- bit.ly/3xjWzLA
Blockchain Tutorial :- bit.ly/3NSbOkc
Corda Tutorial:- bit.ly/3thbUKa
Hyperledger Fabric :- bit.ly/38RZCRB
NoSQL Tutorial :- bit.ly/3aJpRuc
Mysql Tutorial :- bit.ly/3thpr4L
Data Structures using Java :- bit.ly/3MuJa7S
Git Tutorial :- bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
www.telusko.com

Пікірлер: 19
@cehost-tech
@cehost-tech 10 ай бұрын
Tulusko is the best online Tutor I have met.
@agnidhbhattacharya5410
@agnidhbhattacharya5410 Жыл бұрын
I had forgotten what it was, thanks for clearing it once again😂🙌🏻🙌🏻☺❤❣️
@Divine._.Playss
@Divine._.Playss 8 ай бұрын
video starts from 2:35
@shaikmansoor223
@shaikmansoor223 10 ай бұрын
Can we ternary operator in if else statements..?
@nazsar55
@nazsar55 3 ай бұрын
2:26 comment out = ctrl + k then ctrl + c To undo = ctrl + k then ctrl + u
@user-nm7mu2gw6f
@user-nm7mu2gw6f 3 ай бұрын
Thanks
@user-lb4jz2ml5t
@user-lb4jz2ml5t 6 ай бұрын
Ternary ki return value Boolean aaya gi
@sumit1613
@sumit1613 3 ай бұрын
Bro has already tuned for 1.25x😅
@ashensamarasekera.7630
@ashensamarasekera.7630 8 ай бұрын
how to use else if in ternary operator
@relaxationvideosbyteamrela7788
@relaxationvideosbyteamrela7788 Жыл бұрын
if we just keep the "result =0" as just "result" ,will it work the same?although i have tried but i am unsure about other examples,i mean there must be some reason to initialize it to "zero" right???
@agnidhbhattacharya5410
@agnidhbhattacharya5410 Жыл бұрын
Sometimes we put curly braces even when there is only one statement after the condition, is there any requirement for that!? No, it's not req.
@agnidhbhattacharya5410
@agnidhbhattacharya5410 Жыл бұрын
But Initialising depends on conditions, like when you add something to "result" Like result= result + 1. Then you req to put result = 0 or 1 if you multiply and I hope you knew this already 😅😅😅
@agnidhbhattacharya5410
@agnidhbhattacharya5410 Жыл бұрын
But tell me did you get the desired result without Initialising result= 0!? Or Did the complier show "Variable result might not have been initialised " 🥲
@kalki7117
@kalki7117 Жыл бұрын
if i write System.out.println(10
@agnidhbhattacharya5410
@agnidhbhattacharya5410 Жыл бұрын
A in single quotes will give 65... Emojis have some other ascii value... Or can it be that by any chance it got concatenated and giving sone other results!?
@rubeenazabin5863
@rubeenazabin5863 8 ай бұрын
why we are using int result = 0;
@adityanarayanmishra2008
@adityanarayanmishra2008 9 ай бұрын
Underrated.
@mrharsh8474
@mrharsh8474 11 ай бұрын
Unary operator?
@machikakapil2144
@machikakapil2144 9 ай бұрын
🤣3:56 😂
#15 Switch Statement in Java
7:59
Telusko
Рет қаралды 115 М.
100+ Linux Things you Need to Know
12:23
Fireship
Рет қаралды 81 М.
OMG😳 #tiktok #shorts #potapova_blog
00:58
Potapova_blog
Рет қаралды 4,3 МЛН
Khó thế mà cũng làm được || How did the police do that? #shorts
01:00
БОЛЬШОЙ ПЕТУШОК #shorts
00:21
Паша Осадчий
Рет қаралды 8 МЛН
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 46 МЛН
What is the ternary operator ❓
4:41
Bro Code
Рет қаралды 17 М.
#12 If else in Java
12:59
Telusko
Рет қаралды 119 М.
What's new in Java Switch | Switch Statement and Expression
11:09
#21 Class And Object Theory in Java
5:48
Telusko
Рет қаралды 189 М.
The Most Amazing Sudoku Cell We've Ever Uncovered
37:17
Cracking The Cryptic
Рет қаралды 4,9 М.
Fastest Way to Learn ANY Programming Language: 80-20 rule
8:24
Sahil & Sarra
Рет қаралды 767 М.
#53 Packages in Java
12:20
Telusko
Рет қаралды 159 М.
ОБСЛУЖИЛИ САМЫЙ ГРЯЗНЫЙ ПК
1:00
VA-PC
Рет қаралды 472 М.
Опыт использования Мини ПК от TECNO
1:00
Андронет
Рет қаралды 221 М.