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
6 Réponses
+ 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;
+ 2
//Conditional operator:
Int r= a>b? a:b;
// Where a and b are assigned or user defined value
+ 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
}
0
Smaller number is less than the larger number.
Sm < Lm
Lm > Sm
Does that help?
0
The condinal operator :
Varible=expression1 ? expression2 : expression3 ;
That is the Formula
I dont know how I use it in this question
0
Thank you that was so usefull❤️