Instead of the two-step
process of using the DECLARE statement and the _NEW_ operator to declare
and instantiate a Java object, you can use the DECLARE statement to
declare and instantiate the Java object in one step. For example,
in the following line of code, the DECLARE statement declares and
instantiates a Java object and assigns the Java object to the object
reference J:
declare javaobj j("somejavaclass");
The preceding line of
code is equivalent to using the following code:
declare javaobj j;
j = _new_ javaobj("somejavaclass");
A
constructor is a method that you can use to instantiate
a component object and initialize the component object data. For example,
in the following line of code, the DECLARE statement declares and
instantiates a Java object and assigns the Java object to the object
reference J. Note that the only required argument for a Java object
constructor is the name of the Java class to be instantiated. All
other arguments are constructor arguments for the Java class itself.
In the following example, the Java class name,
testjavaclass
, is the constructor, and the values
100
and
.8
are constructor arguments.
declare javaobj j("testjavaclass", 100, .8);