4) Write the conditional operator (ternary operator) for the conditional statement.
if( m==0) System.out.println("hello");
else System.out.println (“Good Day");
Answers
Answered by
1
Answer:
String res = m == 0?"hello":"Good Day";
Sopln(res)
hope this will be helpful for you :)
Answered by
1
Question:-
- Write the following statement using ternary operator.
Solution:-
Given code,
if(m==0)
System.out.println("Hello.");
else
System.out.println("Good Day. ");
The given code can be written using ternary operator as,
System.out.println((m==0)?"Hello.":"Good Day. ");
Similar questions
Science,
3 months ago
Physics,
3 months ago
Science,
3 months ago
Computer Science,
7 months ago
Physics,
7 months ago