Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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
 
PREVIOUS NEXT
Tagged: #java #shorthand
ADD COMMENT
Topic
Name
1+1 =