Any Java method which returns an object type. In addition, you can explicitly construct a
JavaObject using the object's Java constructor with the
JavaClass is the fully-specified name of the object's Java class.
- An optional list of parameters, specified by the constructor of the Java class.
JavaObject is a wrapper for the instance; all references to the class instance are made through the
Inherits public data members from the Java class of which it is an instance as properties. It also inherits public data members from any superclass as properties.
Inherits public methods from the Java class of which it is an instance. The
JavaObject also inherits methods from
java.lang.Object and any other superclass.
The following code creates the
theString, which is an instance of the class
var theString = new Packages.java.lang.String("Hello, world");
String class is in the
java package, you can also use the java synonym and omit the
Packages keyword when you instantiate the class:
var theString = new java.lang.String("Hello, world");
Example: Accessing methods of a Java object
theString is an instance of
java.lang.String, it inherits all the public methods of
java.lang.String. The following example uses the
startsWith method to check whether
theString begins with "Hello".
var theString = new java.lang.String("Hello, world"); theString.startsWith("Hello"); // returns true
Example: Accessing inherited methods
getClass is a method of
String class inherits the
getClass method. Consequently,
getClass is also a method of the
JavaObject which instantiates
var theString = new java.lang.String("Hello, world"); theString.getClass(); // returns java.lang.String