This article takes a look at the bytecodes that manipulate objects and arrays. By Bill Venners elcome to another edition of Under The Hood . This column focuses on Java's underlying technologies. It aims to give developers a glimpse of the mechanisms that make their Java programs run. This month's article takes a look at the bytecodes that deal with objects and arrays.
Objects reside on the garbage- collected heap.
Object references and primitive types reside either on the Java stack as local variables, on the heap as instance variables of objects, or in the method area as class variables. In the Java virtual machine, memory is allocated on the garbage-collected heap only as objects. There is no way to allocate memory for a primitive type on the heap, except as part of an object. If you want to use a primitive type where an Object reference is needed, you can allocate a wrapper object for the type from the java.lang package. For example, there is an Integer class that wraps an int type with an object.