当前位置: 代码迷 >> Eclipse >> java新生初学者,求点化.
  详细解决方案

java新生初学者,求点化.

热度:53   发布时间:2016-04-23 12:26:57.0
java新生菜鸟,,,求点化...
回去专科大二,大一赶完了C的皮毛,,,
匆匆忙,暑假总结C皮毛,学java。。。
软件全部是官网的JDK1.6.0 SE、eclipse 3.6.2
下了孙鑫老师的java视频教学,前辈们几年前在dos...真是不容易。


学习/继承-构造函数/的代码:

class Animal {
int height,weight;
Animal(){
System.out.println("Animal construction");
}
void eat(){
System.out.println("Animal eat");
}
void sleep(){
System.out.println("Animal sleep");
}
void breathe(){
System.out.println("Animal breathe");
}
}


class Fish extends Animal{
Fish(){
System.out.println("Fish construction");
}
void breathe(){
System.out.println("Fish bubble");
}
}


class Integration{
public static void main(String[] args){
// Animal al=new Animal;
Fish fh=new Fish();
// al.breathe();
// fh.height=20;
// fh.weight=30;

}


为什么eclipse就不运行代码呢???
说是没有main...

dos下,javac Animal+java Integration就可以。。。


------解决方案--------------------
代码可以编译,但是没有main方法所以不能运行。

javac只是build成class文件没有真正运行。
------解决方案--------------------
在eclipse里代码是可以运行的,没什么问题。

在你的主类integration上右键单击,Run As --〉 Run Configurations 

Main 标签页里选择 Project 为你当前的project,选择Main.class 为你的主类Integration

然后点击Run
  相关解决方案