Answers for "java if else short"

4

java shorthand if

//Clear example with good readabilty
String var = "Text";
String shortHand = (var.equals("Text") ? "Returns this if true" : "Returns this if false");

//Other example that is less readable
int var = 9;
int shortHand = var == 9 ? 1 : var++;

//Pseudo code
// CONDITION ? returns when true : returns when false
Posted by: Guest on June-12-2021
1

java shortest if else statement

(myNumber == 12) ? "true" : "false"
Posted by: Guest on May-21-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language