describe the operator in java langaugethe


Describe The ? operator in Java langauge?

The conditional operator just works for assigning a value to a variable, using a value within a method invocation, or in a few other way that indicates the type of its second and third arguments. For instance, consider the subsequent

if (name.equals("Rumplestiltskin")) {
System.out.println("Give back child");
}
else {
System.out.println("Laugh");
}
This may not be written like this:
name.equals("Rumplestiltskin")
? System.out.println("Give back child")
: System.out.println("Laugh");

First of all, both the second and third arguments are void. Other than, no assignment is present to denote the type in which is expected for the second and third arguments (though you know void must be wrong).

The first argument to the conditional operator must have or return Boolean type and the second and third arguments must return values compatible along with the value the whole expression can be expected to return. You could never use a void techniques as an argument to the ? : operator.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: describe the operator in java langaugethe
Reference No:- TGS0284418

Expected delivery within 24 Hours