In this java article, we will be covering conditional assignment. In java, we can assign perform conditional assignments depend on result of a condition as true or false.
Lets look to syntax of explicit type conversation.
int x = 5;
int y= 17;
String result = x > y ? "greater" : "smaller";
Lets see it in Java code example.
In above example, we declared 3 type of variable. We told compiler that value of result will be string and "greater" if "x" is greater than "y", otherwise to be "smaller". Finally, to check to value of "result", we print it to terminal output.