7.5. Constructors

A constructor is a way of creating an object. The most common way to do this is using the new keyword, as we have done a number of times already:

Type ObjectName = new Type(arguments); 

When you write this statement, the runtime determines if there is enough memory space to create your object and the data that it will hold. If there is enough, the object is created and set to its initial state. If there is not enough space, then the runtime looks for space it can reclaim and runs the garbage collector to reclaim it. The garbage collector destroys items with no references, as they could no longer be necessary to a program's life. If there is still not enough free space, an OutOfMemoryError exception is thrown.

Once an object ...

Get Java™ for ColdFusion® Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.