Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.arcetri.astro.it/irlab/doc/library/javascript/clientreference/javobj.htm
Дата изменения: Thu Oct 7 13:13:36 1999 Дата индексирования: Sat Dec 22 14:24:02 2007 Кодировка: Поисковые слова: с р р с с п п р п п с с с р р р р р п п р р р п п р |
JavaObject
using the object's Java constructor with the Packages
keyword:
new Packages.JavaClass(parameterList)where JavaClass is the fully-specified name of the object's Java class.
parameterList | An optional list of parameters, specified by the constructor in the Java class. |
JavaObject
object is an instance of a Java class that is created in or passed to JavaScript. JavaObject
is a wrapper for the instance; all references to the class instance are made through the JavaObject
.
Any Java data brought into JavaScript is converted to JavaScript data types. When the JavaObject
is passed back to Java, it is unwrapped and can be used by Java code. See the Client-Side JavaScript Guide for more information about data type conversions.
JavaObject
also inherits methods from java.lang.Object
and any other superclass.
JavaObject
theString
, which is an instance of the class java.lang.String
:
var theString = new Packages.java.lang.String("Hello, world")Because the
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 2. Accessing methods of a Java object. Because the
JavaObject
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")Example 3. Accessing inherited methods. Because
theString.startsWith("Hello") // returns true
getClass
is a method of Object
, and java.lang.String
extends Object
, the String
class inherits the getClass
method. Consequently, getClass
is also a method of the JavaObject
which instantiates String
in JavaScript.
var theString = new java.lang.String("Hello, world")
theString.getClass() // returns java.lang.String
JavaArray
, JavaClass
, JavaPackage
, Packages
Last Updated: 05/28/99 11:59:41