-
Enhancement
-
Resolution: Fixed
-
P4
-
1.4.0
-
beta
-
generic
-
generic
Name: rmT116609 Date: 12/07/2001
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
Frequently in Java newsgroups, people ask how to get the Class object associated
with the current class. There is an easy solution which is totally undocument in the
API documentation. In the class Class, where you talk about getName(), also
include a reference to Foo.class as the Class object, e.g.
public class Foo {
static public void main(String args[]) {
System.out.println(Foo.class.getName());
}
}
Newsgroup replies sometimes suggest using forName, which is so much slower.
Searches on java.sun.com do not easily turn this up. Add it to FAQs. Document
it. This is so easy to fix.
(Review ID: 136928)
======================================================================