我有一段代码,很简单!但用jdk能编译过去,但就是不能运行出结果来!请帮忙阿!!(50分)

F

foxman

Unregistered / Unconfirmed
GUEST, unregistred user!
我有一段代码,很简单!但用jdk能编译过去,但就是不能运行出结果来!请帮忙阿!!
class abTest{
private int a=0,b=0;
void ant(int x){
a=x;
int b=5;
System.out.println("in init:");
System.out.println("a="+a+"b="+b);
}
void show(){
System.out.println("a="+a+"b="+b);
}


abTest ano=new abTest();
System.out.println("before init");
ano.show();
ano.ant(6);
System.out.println("after init");
ano.show();


}
 
少了main,当然不能运行出结果来。
package untitled1;
class abTest{
private int a=0,b=0;
void ant(int x){
a=x;
int b=5;
System.out.println("in init:");
System.out.println("a="+a+"b="+b);
}
void show(){
System.out.println("a="+a+"b="+b);
}
static public void main(String[] args) {
abTest ano=new abTest();
System.out.println("before init");
ano.show();
ano.ant(6);
System.out.println("after init");
ano.show();
}
}
 
老兄,家了main后还是不行啊!
编译器老是说没有main这个方法!
请在帮帮忙啊!
 
光有类的定义,没有入口点,有什么用呢,而且看你的代码问题不少呢
 
我上面的代码在JBuilder7中运行的结果如下:
before init
a=0b=0
in init:
a=6b=5
after init
a=6b=0
因此,是jdk的使用问题。
 
在JBuilder中如何设置运行,我没能搞的出来
能不能告诉我具体该怎样操作啊!(我是菜鸟啊!)
 
在JBuilder7的菜单中Run-Configurations...-New...-Application
main class:untitled1.abTest
如果你用JDK,要用如下的命令行:
java -classpath . abTest
你可以看一下下面的帖子:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=654858
 
谢谢你!我会啦!
 
顶部