Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Automated update-Scrapy V0.1 Fixing Navigation links Automatic Nagivation Script

The conditional operator ?: uses the boolean value of its first operand to decide which of the other two expressions will be evaluated. (See §15§15.25, "Conditional Operator ? :" of the Java Language Specification [JLS 2005].)

...

Rule

Operand 2

Operand 3

Resultant type

1

type T

type T

type T

2

boolean

Boolean

boolean

3

Boolean

boolean

boolean

4

null

reference

reference

5

reference

null

reference

6

byte or Byte

short or Short

short

7

short or Short

byte or Byte

short

8

byte, short, char, Byte, Short, Character

constant int

byte, short, char if value of int is representable

9

constant int

byte, short, char, Byte, Short, Character

byte, short, char if value of int is representable

10

other numeric

other numeric

promoted type of the 2nd and 3rd operands

11

T1 = boxing conversion (S1)

T2 = boxing conversion(S2)

apply capture conversion to lub(T1,T2)

See §5§5.1.7, "Boxing Conversion"; §5§5.1.10, "Capture Conversion"; and §15§15.12.2.7, "Inferring Type Arguments Based on Actual Arguments" of the Java Language Specification for additional information on the final table entry.

...

Wiki Markup
\[[Bloch 2005|AA. Bibliography#Bloch 05]\] Puzzle 8: Dos Equis
\[[Findbugs 2008|AA. Bibliography#Findbugs 08]\] "Bx: Primitive value is unboxed and coerced for ternary operator"
\[[JLS 2005|AA. Bibliography#JLS 05]\] [§15§15.25|http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.25], "Conditional Operator {{? :}}"

...

Image RemovedEXP11-J. Never dereference null pointers      02. Expressions (EXP)      Image Removed03. Numeric Types and Operations (NUM)