what is question mark in java code example

Example 1: what does question mark mean in java

boolean statement ? true result : false result;

/*
For example, if we take this if statement:
*/
if (a > b) {
    result = x;
} else {
    result = y;
}
// can be also writen:
result = a > b ? x : y;

Example 2: java sql question mark

ODBCCommand cmd = new ODBCCommand("SELECT thingA FROM tableA WHERE thingB = ?")
cmd.Parameters.Add(7)
result = cmd.Execute()

Example 3: if statement using question mark java

boolean statement ? "true result" : "false result";

Tags:

Java Example