Check out example codes for "java ternary operator". It will help you in understanding the concepts better.

Code Example 1

booleanExpression ? expression1 : expression2;

Code Example 2

// variable= condition ? value if condition is True : value if condition is false
// only ternary operator in java
int max,a=1,b=2;
max= a>b ? a : b;

//will result in max = b

Code Example 3

Object myObject = booleanExpression ? valueIfTrue : valueIfFalse;

Code Example 4

variable = (condition/expression1) ? expression2 if true : expression3 if false

Learn ReactJs, React Native from akashmittal.com