20.3
java.lang.Class
THE PACKAGE JAVA.LANG
20.3 The Class
java.lang.Class
Instances of the class
Class
 represent classes and interfaces in a way that can be
manipulated by a running Java program. Every array also belongs to a class repre 
sented by a
Class
 object that is shared among all arrays with the same element
type and number of dimensions.
There is no public constructor for the class
Class
. The Java Virtual Machine
automatically constructs
Class
 objects as classes are loaded; such objects cannot
be created by user programs.
public final class Class {
public String toString();
public String getName();
public boolean isInterface();
public Class getSuperclass();
public Class[] getInterfaces();
public Object newInstance()
throws InstantiationException, IllegalAccessException;
public ClassLoader getClassLoader();
public static Class forName(String className)
throws ClassNotFoundException;
}
20.3.1
public String toString()
If this
Class
 object represents a class (which may be a declared class or an array
class), a string is returned consisting of the word
class
, a space, and the name of
the class as returned by the
getName
 method ( 20.3.2). If this
Class
 object repre 
sents an interface, a string is returned consisting of the word
interface
, a space,
and the name of the interface as returned by the
getName
 method.
In other words, this method returns a string equal to the value of:
(isInterface() ? "interface " : "class ") + getName()
Overrides the
toString
 method of
Object
 ( 20.1.2).
20.3.2
public String getName()
The fully qualified name of the class or interface represented by this
Class
 object
is returned as a
String
. For example:
new Object().getClass().getName()
returns
"java.lang.Object"
.
466






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved