0
我正在使用.getDeclaredClasses()方法檢索已在對象中定義的所有類。但是,我無法檢索類中定義的匿名類。下面是我測試的代碼示例:使用Java反射檢索成員類
public class TempCodes
{
public static void main(String[] args)
{
Ball b = new Ball()
{
public void hit()
{
System.out.println("You hit it!");
}
};
b.hit();
}
interface Ball {
void hit();
}
}
,這就是我的代碼呢:
memClass = className.getDeclaredClasses();
if (memClass .length > 0)
{
for (int index = 0 ; index < memClass .length ; index++)
{
System.out.println("\t\t\t" + memClass [index]);
}
}
誰能幫助我瞭解如何獲取匿名類?
問候, darkie
http://stackoverflow.com/questions/2679924/using-java-reflections-to-retrieve-member-classes – 2010-04-21 02:34:49
@Michael:無限循環! – BalusC 2010-04-21 02:39:21
該帖子的任何問題? – 2010-04-21 02:45:11