[ Team LiB ] 6.5 Completing the Type

[ Team LiB ] 6.5 Completing the Type Hierarchy Table 6.1 summarizes the types found in Java. Only primitive data and reference values can be stored in variables. Only class and array types can be instantiated to create objects. Table 6.1. Types and Values Types Values Primitive data types Primitive data values Class, interface, and array types (reference types) Reference values Arrays are objects in Java. Array types (boolean[], Object[], StackImpl[]) implicitly augment the inheritance hierarchy. The inheritance hierarchy depicted in Figure 6.3 can be augmented by the corresponding array types. The resulting type hierarchy is shown in Figure 6.4. An array type is shown as a “class” with the [] notation appended to the name of the element type. The class SafeStackImpl is a subclass of the class StackImpl. The corresponding array types, SafeStackImpl[] and StackImpl[], are shown as subtype and supertype, respectively, in the type hierarchy. Figure 6.4 also shows array types corresponding to some of the primitive data types. Figure 6.4. Reference Type Hierarchy From the type hierarchy in Figure 6.4, we can summarize the following: . All reference types are subtypes of Object type. This applies to classes, interfaces, and array types, as these comprise all reference types. . All arrays of reference types are also subtypes of the array type Object[], but arrays of primitive data types are not. Note that the array type Object[] is also a subtype of Object type. . If a reference type is a subtype of another reference type, then the corresponding array types also have an analogous subtype-supertype relationship. . There is no subtype-supertype relationship between a type and its corresponding array Page 325
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check Actions tomcat hosting services

Comments are closed.