COMPSCI 61B Lecture Notes - Lecture 13: Avocado
Document Summary
Generic classes require us to provide one or more actual type arguments. Generics can"t hold primitive types (must use their respective reference type) Wrapper types and primitives can be used almost interchangeably. Arrays are never autoboxed or unboxed (integer[] can"t be used in place of int[]) Autoboxing / unboxing incurs a measurable performance impact. Wrapper types use much more memory than primitive types. Java objects have addresses that take up 64 bits and additional elds public static void bleepblorp(cid:383)(cid:384) { A value is promoted when it moves from a primitive type with a narrower range to a wider range (int to double) To move from a wider format to a narrower format, you must use casting (e. g. casting from double to int) An immutable data type is one for which an instance cannot change in any observable way after instantiation. The final keyword helps the compiler ensure immutability. You will assign a value only once (constructor or initializer)