20.3
java.lang.Class
THE PACKAGE JAVA.LANG
in the array corresponds to the order of the interface names in the
implements
clause of the declaration of the class represented by this
Class
object. For exam
ple, given the class declaration:
class Shimmer implements FloorWax, DessertTopping { ... }
suppose the value of
s
is an instance of
Shimmer
; the value of the expression:
s.getClass().getInterfaces()[0]
is the
Class
object that represents interface
FloorWax
; and the value of:
s.getClass().getInterfaces()[1]
is the
Class
object that represents interface
DessertTopping
.
If this
Class
object represents an interface, the array contains objects repre
senting all interfaces directly extended by the interface that is, the immediate
superinterfaces of the interface. The order of the interface objects in the array cor
responds to the order of the interface names in the
extends
clause of the declara
tion of the interface represented by this
Class
object.
20.3.6
public Object newInstance()
throws InstantiationException, IllegalAccessException
This method creates and returns a new instance of the class represented by this
Class
object. This is done exactly as if by a class instance creation expression
( 15.8) with an empty argument list; for example, if
t
is the
Class
object that rep
resents class
Thread
, then
t.newInstance()
does exactly the same thing as
new
Thread()
. If evaluation of such a class instance creation expression would com
plete abruptly, then the call to the
newInstance
method will complete abruptly
for the same reason. See also 11.5.1.2 for more on
InstantiationException
.
20.3.7
public ClassLoader getClassLoader()
This method returns a reference to the class loader ( 20.14) that loaded this class.
If this class has no class loader, then
null
is returned.
20.3.8
public static Class forName(String className)
throws ClassNotFoundException
Given the fully qualified name of a class, this method attempts to locate, load, and
link the class ( 12.2). If it succeeds, then a reference to the
Class
object for the
class is returned. If it fails, then a
ClassNotFoundException
is thrown.
468
footer
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