A reference to the class name used with the Packages object:
where JavaClass is the fully-specified name of the object's Java class. The LiveConnect java, sun, and netscape objects provide shortcuts for commonly used Java packages and also create JavaClass objects.
You can pass a JavaClass object to a Java method which requires an argument of type java.lang.Class.
The properties of a JavaClass object are the static fields of the Java class.
The methods of a JavaClass object are the static methods of the Java class.
Example 1. In the following example, x is a JavaClass object referring to java.awt.Font. Because BOLD is a static field in the Font class, it is also a property of the JavaClass object.
x = java.awt.Font
myFont = x("helv",x.BOLD,10) // creates a Font object
The previous example omits the Packages keyword and uses the java synonym because the Font class is in the java package.
Example 2. In the following example, the JavaClass object java.lang.String is passed as an argument to the newInstance method which creates an array:
var cars = java.lang.reflect.Array.newInstance(java.lang.String, 15)
Previous Contents Index Next
JavaArray, JavaObject, JavaPackage, Packages
Content is available under these licenses.
Last Updated September 28, 2000