please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

getClass() Function

Name

getClass() Function---return the JavaClass of a JavaObject

Availability

Navigator 3.0

Synopsis

getClass(javaobj)

Arguments

javaobj

A JavaObject object.

Returns

The JavaClass object of javaobj.

Description

getClass() is a function that takes a JavaObject object (javaobj) as an argument. It returns the JavaClass object that JavaObject. That is, it returns the JavaClass object that represents the Java class of the Java object represented by the specified JavaObject.

Usage

Don't confuse the JavaScript getClass() function with the getClass method of all Java objects. Similarly, don't confuse the JavaScript JavaClass object with the Java java.lang.Class class.

Consider the Java rectangle object created with the following line:

var r =index.html new java.awt.Rectangle();

r is a JavaScript variable that holds a JavaObject object. Calling the JavaScript function getClass() returns a JavaClass object that represents the java.awt.Rectangle class:

var c =index.html getClass(r);

You can see that this is so by comparing this JavaClass object to java.awt.Rectangle:

if (c ==index.html java.awt.Rectangle) ...

The Java getClass() method is invoked differently and performs an entirely different function:

c =index.html r.getClass();

After executing the above line of code, c is a JavaObject that represents a java.lang.Class object. This java.lang.Class object is a Java object that is a Java representation of the java.awt.Rectangle class. See your Java documentation for details on what you can do with the java.lang.Class class.

To summarize, you can see that the following expression will always evaluate to true, for any JavaObject o:

(getClass(o.getClass()) ==index.html java.lang.Class)

See Also

"java", "JavaArray", "JavaClass", "JavaObject", "JavaPackage", "Packages", Chapter 19, LiveConnect: JavaScript and Java


Previous Home Next
Function.toString() Book Index Hidden

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/java/script/definitive/refp_148.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/27 00:07,
TOP NEW HELP FIND: 
3.15.203.246:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://ecomorder.com/techref/language/java/script/definitive/refp_148.htm"> [Chapter 21] Reference: getClass()</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .