展会信息港展会大全

eclipse运行java程序时要求Select Java Application
来源:互联网   发布日期:2016-01-14 14:22:30   浏览:2789次  

导读:在eclipse中运行一个JavaApp,总是弹出这样一个窗口:上代码:[java]package com.tao.pattern;import java.lang.r...

在eclipse中运行一个JavaApp,总是弹出这样一个窗口:

上代码:

[java]

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{

}

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{

}

打印结果:

[java]

show

main

getClass

hashCode

equals

toString

notify

notifyAll

wait

wait

wait

show

main

getClass

hashCode

equals

toString

notify

notifyAll

wait

wait

wait

可以发现,在子类中,继承了父类的main方法,所以导致一个类文件中,有两个main方法,所以才会弹出上面的窗口,让你选择。

赞助本站

人工智能实验室

相关热词: java 教程

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港