我想在方法中引用类的名称。在下面的例子中,我想要打印出TestSuite。我可以放CarsTestSuite.class.getName()
,但我想使用该方法来获取类名,这样我就不必编辑它。该解决方案将找到方法的类,而不是我自己加油吧。从方法中获取类名
public class TestSuite extends TestCase {
public static void testOne() {
System.out.println(<want TestSuite to be here>);
不,它不需要是静态的,上面的例子:this.getClass()。getName()工作。谢谢。 – 2010-07-14 16:34:08