Java for beginners | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Java for beginners

Write Java program that read tow numbers of user and print the greatest number using the ternary Java operator “?” I just need the conditional operator

8th Oct 2022, 8:43 PM
Roo s
6 Answers
+ 7
provided that the two numbers are a and b, you can express the maximum of them like so: int max = a>b ? a : b;
8th Oct 2022, 9:12 PM
Tibor Santa
Tibor Santa - avatar
+ 2
//Conditional operator: Int r= a>b? a:b; // Where a and b are assigned or user defined value
9th Oct 2022, 5:36 AM
𝓐𝓷𝓼𝓱𝓲𝓴𝓪 (Anshika)
𝓐𝓷𝓼𝓱𝓲𝓴𝓪 (Anshika) - avatar
+ 2
This is simplification of if and else or true or false. Ex. Variable = user online Variable is the user online? If yes, say hello(true) : if not, I'll wait for you(false) Now let's address the if and else if(user is online){ Say hello }else{ Say I'll wait for you }
9th Oct 2022, 12:26 PM
Félix Zamdamela
Félix  Zamdamela - avatar
0
Smaller number is less than the larger number. Sm < Lm Lm > Sm Does that help?
8th Oct 2022, 8:48 PM
Ausgrindtube
Ausgrindtube - avatar
0
The condinal operator : Varible=expression1 ? expression2 : expression3 ; That is the Formula I dont know how I use it in this question
8th Oct 2022, 8:52 PM
Roo s
0
Thank you that was so usefull❤️
8th Oct 2022, 9:22 PM
Roo s