To use a DATA step component
object in your SAS program, you must declare and create (instantiate)
the object. The DATA step component interface provides a mechanism
for accessing the predefined component objects from within the DATA
step.
If you use the _NEW_
operator to instantiate the Java object, you must first use the DECLARE
statement to declare the Java object. For example, in the following
lines of code, the DECLARE statement tells SAS that the object reference
J is a Java object. The _NEW_ operator creates the Java object and
assigns it to the object reference J.
declare javaobj j;
j = _new_ javaobj("somejavaclass" );
Note: You can use the DECLARE statement
to declare and instantiate a Java object in one step.
A constructor is a method
that is used to instantiate a component object and to initialize the
component object data. For example, in the following lines of code,
the _NEW_ operator instantiates a Java object and assigns it 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;
j = _new_ javaobj("testjavaclass", 100, .8);