Declares a Java object; creates an instance of and initializes data for a Java object.
Alias: | DCL |
specifies the object reference name for the Java object.
specifies the name of the Java class to be instantiated.
Requirements | The Java class name must be enclosed in either double or single quotation marks. |
If you specify a Java package path, you must use forward slashes (/) and not periods (.) in the path. For example, an incorrect class name is "java.util.Hashtable". The correct class name is "java/util/Hashtable". |
specifies the information that is used to create an instance of the Java object. Valid values for argument depend on the Java object.
See | Using the DECLARE Statement to Instantiate a Java Object (Form 2) |
declare javaobj j;
j = _new_ javaobj("somejavaclass");
declare javaobj j("somejavaclass");
declare javaobj j; j = _new_ javaobj("somejavaclass");
testjavaclass
, is
the constructor, and the values 100
and .8
are
constructor arguments.
declare javaobj j("testjavaclass", 100, .8);
/* Java code */ import java.util.*; import java.lang.*; public class simpleclass { public int i; public double d; }
/* DATA step code data _null_; declare javaobj myjo; myjo = _new_ javaobj("simpleclass"); run;
mhash
,
is necessary because the DATA step's only numeric type is equivalent
to the Java type DOUBLE.
/* Java code */ import java.util.*; public class mhash extends Hashtable; { mhash (double size, double load) { super ((int)size, (float)load); } }
/* DATA step code */ data _null_; declare javaobj h("mhash", 100, .8); run;