Is it possible to access the Class object in a static method?
Posted
by Bears will eat you
on Stack Overflow
See other posts from Stack Overflow
or by Bears will eat you
Published on 2010-04-15T18:47:20Z
Indexed on
2010/04/15
18:53 UTC
Read the original article
Hit count: 103
java
Consider the following Java class:
public class Foo
{
public static void doStuff()
{
// boring stuff here
}
}
Is it possible to access either the class literal Foo.class
, or just the class name "Foo"
from within a static method such as doStuff()
? In a non-static method I would just call this.getClass()
, but there is no this
to use in a static method.
© Stack Overflow or respective owner