4.9. Intersection Types

An intersection type takes the form T1 & ... & Tn (n > 0), where Ti (1 ≤ in) are type expressions.

Intersection types arise in the processes of capture conversion (§5.1.10) and type inference (§15.12.2.7). It is not possible to write an intersection type directly as part of a program; no syntax supports this.

The values of an intersection type are those objects that are values of all of the types Ti for 1 ≤ in.

The members of an intersection type T1 & ... & Tn are determined as follows:

• For each Ti (1 ≤ in), let Ci be the most specific class or array type such that Ti <: Ci. Then there must be some Tk <: Ck such that Ck <: Ci for any i (1 ≤ in), or a compile-time error occurs.

• For 1 ≤ jn, if Tj is a ...

Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.