it is possible in java ternary operation? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

it is possible in java ternary operation?

18th Aug 2018, 11:12 AM
Real Gutch
Real Gutch - avatar
7 Answers
+ 15
Gutch From Ph //its the same as if,else statments int x = 100; System.out.print(x>50?"yes":"no"); // same as if(x>50){ System.out.print("yes");} else{System.out.print("no");}
18th Aug 2018, 11:38 AM
D_Stark
D_Stark - avatar
+ 12
if its possible with if and else statements then its possible with ternery i made this using ternary https://code.sololearn.com/cuowj1Lgng4q/?ref=app
18th Aug 2018, 11:18 AM
D_Stark
D_Stark - avatar
+ 7
ty bro😇
18th Aug 2018, 11:51 AM
Real Gutch
Real Gutch - avatar
+ 6
Thanks guys because my first ternary in java does'nt work 😃
18th Aug 2018, 11:29 AM
Real Gutch
Real Gutch - avatar
+ 3
Yes, it's possible. You can see some examples here https://www.tutorialspoint.com/Java-Ternary-Operator-Examples
18th Aug 2018, 11:19 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 2
When if and else works. Ternary works too provided you have not violated the syntax
29th Aug 2018, 3:07 AM
karthikeyan
karthikeyan - avatar
+ 1
yes like c and c++ it is possible... just try it out
18th Aug 2018, 2:40 PM
Aarav Raj
Aarav Raj - avatar