Computer Applications
Find the error in the given statement:
int x = (a => b) ? "a" : "b";
int x = (a => b) ? "a" : "b";
Java Conditional Stmts
11 Likes
Answer
- => is an invalid operator. it should be >=
- Type of x should be String.
Corrected Statement
String x = (a >= b) ? "a" : "b";
Answered By
7 Likes
Related Questions
Rewrite the following statement using if else:
int max=215, min=323; String str= (max>min) ? "Max is greater than Min" : "Min is Greater than Max";
Write the following switch statement by using nested if statements:
switch (choice) { case 0: case 1: x = 111; y = 222; break; case 2: x = 333; y = 444; break; case 3: x = -11; y = -22; break; default: y = 555; }
Write an if statement to find the smallest of the three given integers using the min() method of the Math class.
Find the error, if any, in the following code. Write the correct statement.
int a=5, b=10; int x = (a>b)>true:false;