|
| GAMES++ |
|
|
|
 |
|
| BROWSER UTILITIES |
|
|
|
 |
|
| AFFILIATES |
|
|
|
 |
|
| ADVERTISEMENT |
|
|
|
 |
|
Get The Class Name From A Static Method
Java: How To
public class ClassFromStatic
{
public static void main(java.lang.String[] args)
{
someStaticMethod();
}
public static void someStaticMethod()
{
System.out.println("I'm in " + new CurrentClassGetter().getClassName()
+ " class");
}
public static class CurrentClassGetter extends SecurityManager
{
public String getClassName()
{
return getClassContext()[1].getName();
}
}
}
|
|
|