Object type
Encyclopedia
|
| Tutorials | Encyclopedia | Dictionary | Directory |
|
Object type
In computer science, an object type (a.k.a. wrapping object) is a datatype which is used in object-oriented programming to wrap a non-object type to make it look like an object. Some object-oriented programming languages make a distinction between objects and non-objects, often referred to as primitive types, for reasons such as runtime efficiency and syntax or semantic issues. For example, Java has primitive wrapper classes corresponding to each primitive type: BoxingBoxing is to place a primitive type within an object so that the primitive can be used as an object, in a language where there is a distinction between a primitive type and an object type. For example, lists may have certain methods which arrays might not, but the list might also require that all of its members be objects. In this case, the added functionality of the list might be unavailable to a simple array of numbers. For a more concrete example, in Java, a can change its size, but an array must have a fixed size. One might desire to have a To get around this, AutoboxingAutoboxing is the term for treating a primitive type as an object type without any extra source code. The compiler automatically supplies the extra code needed to perform the type conversion. For example J2SE 5.0 allow the programmer to create a This action is called autoboxing, because it is done automatically and implicitly instead of requiring the programmer to do so manually. UnboxingUnboxing refers to a boxed primitive type which has been broken down and the primitive type retrieved for a process of some kind such as a mathematical operation. For example, in versions of Java prior to J2SE 5.0, the following code did not compile: Integer i = new Integer(9); Integer j = new Integer(13); Integer k = i + j; // error in versions prior to 5.0! As of J2SE 5.0, the int i = 9; int j = 13; int k = i + j; Another example: int x = 4; int y = 5; // Integer qBox = new Integer(x + y); Integer qBox = x + y; // would have been an error, but okay now - equivalent to previous line
Source: Wikipedia | The above article is available under the GNU FDL. | Edit this article
|
|
top
©2008-2009 TutorGig.com. All Rights Reserved. Privacy Statement