在eclipse中运行一个JavaApp,总是弹出这样一个窗口:
参考下面这篇文章:http://blog.csdn.net/ieeeitu/article/details/6955207,依然没有解决,最后才发现时很简单的一个问题造成的。上代码:
package com.tao.pattern;
import java.lang.reflect.Method;
public class Father {
public static void main(String[] args) {
Son son=new Son();
Method[] methods =son.getClass().getMethods();
for(Method m:methods){
System.out.println(m.getName());
}
}
public void show(){
}
}
class Son extends Father{
}
打印结果:
show
main
getClass
hashCode
equals
toString
notify
notifyAll
wait
wait
wait 可以发现,在子类中,继承了父类的main方法,所以导致一个类文件中,有两个main方法,所以才会弹出上面的窗口,让你选择。