language-icon Old Web
English
Sign In

Object type

In computer science, an object type (a.k.a. wrapping object) is a datatype that is used in object-oriented programming to wrap a non-object type to make it look like a dynamic object. In computer science, an object type (a.k.a. wrapping object) is a datatype that is used in object-oriented programming to wrap a non-object type to make it look like a dynamic object. Some object-oriented programming languages make a distinction between reference and value types, often referred to as objects and non-objects on platforms where complex value types don't exist, for reasons such as runtime efficiency and syntax or semantic issues. For example, Java has primitive wrapper classes corresponding to each primitive type: Integer and int, Character and char, Float and float, etc. Languages like C++ have little or no notion of reference type; thus, the use of object type is of little interest. Boxing, otherwise known as wrapping, is the process of placing a primitive type within an object so that the primitive can be used as a reference object. For example, in Java, a LinkedList can change its size, but an array must have a fixed size. One might desire to have a LinkedList of int, but the LinkedList class only lists references to dynamic objects—it cannot list primitive types, which are value types. To circumvent this, int can be boxed into Integer, which are dynamic objects, and then added to a LinkedList of Integer. (Using generic parameterized types introduced in J2SE 5.0, this type is represented as LinkedList<Integer>.)On the other hand, C# has no primitive wrapper classes, but allows boxing of any value type, returning a generic Object reference. The boxed object is always a copy of the value object, and is usually immutable. Unboxing the object also returns a copy of the stored value. Repeated boxing and unboxing of objects can have a severe performance impact, because boxing dynamically allocates new objects and unboxing (if the boxed value is no longer used) then makes them eligible for garbage collection. However, modern garbage collectors such as the default Java HotSpot garbage collector can more efficiently collect short-lived objects, so if the boxed objects are short-lived, the performance impact may not be so bad.

[ "Computer vision", "Database", "Artificial intelligence", "Programming language", "Object (computer science)", "Uniqueness type" ]
Parent Topic
Child Topic
    No Parent Topic