java 示例2——Get the class name in a static method
2011-03-17 17:27
645 查看
FromWhere.javapackage com.wenjx.aboutClass; 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(); } } }程序输出为:I'm in com.wenjx.aboutClass.ClassFromStatic class
相关文章推荐
- How to call getClass() from a static method in Java?
- java示例3——Get the current method name
- Java Class.forName、Class.class、getClass示例区分
- he method get(Class, Serializable) in the type HibernateTemplate is not applicable for the arguments
- When to use static method in a java class
- Relationship between java file name and the declared class name in it
- The longest class name in Java and .NET Framework
- Java反射之Method Class.getMethod(String name, Class<?>... parameterTypes)
- What is the difference between @staticmethod and @classmethod in Python?
- whether the results are the same of getClass().getName() called in child class and parent class?
- Java反射之Method Class.getMethod(String name, Class<?>... parameterTypes)
- java.lang.IllegalStateException: Could not find a method capture(View) in the activity class
- java.lang.IllegalStateException: Could not find a method false(View) in the activity class com.xuan
- The Difference of Class.forName()、Class.forName().newInstance() and New in Java
- When to use static method in a java class
- java.lang.NoSuchMethodError: No static method hasOnClickListeners(Landroid/view/View;)Z in class Lan
- Partial mock local private method or public method in the class and suppress static initial block
- java.lang.NoSuchMethodError: No static method getFont
- Access restriction: The method typeNameToClass(String) from the type ObjectHandler is not accessible due to restriction on required library
- Java中反射机制和Class.forName、实例对象.class(属性)、实例对象getClass()的区别