Java Objects

In addition to supporting the definition of variables of the Java data types, IMLPlus also supports the definition of variables that refer to Java objects. To disambiguate object-reference variable definitions from other program statements, IMLPlus requires that object-reference variable definitions begin with the keyword declare.

Examples:

declare String sTitle;
declare mypackage.myclass object;

Object-reference variable definitions do not create (instantiate) new Java objects but rather define a variable that can be used to refer to an object of a specific class. Be aware of the fact that object-reference variables follow reference semantics rather than value semantics. The assignment statement

object2 = object1;

merely causes variable object2 to refer to the same object as does variable object1. As in Java, you use the new operator to create another object.