您的位置:程序门 -> java -> j2se / 基础类



jcreator4的问题??


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


jcreator4的问题??[已结贴,结贴人:michael_bb]
发表于:2007-04-19 21:18:10 楼主
//filename: people_test.java

//定义people类
class   people{
public   people(){
height   =   0;
weight   =   0;
}
      public   double   height,weight;
      public   void   speak_hello(){
  system.out.println( "hello! ");
      }
        public   void   average_height(){
        system.out.println(height);
        }
        public   void   average_weight(){
        system.out.println(weight);
        }
}

//定义china_people
class   china_people   extends   people{
public   void   china_gongfu(){
system.out.println( "坐如钟,站如松,睡如弓 ");
}
public   void   speak_hello(){
system.out.println( "你好,吃饭了吗 ");
}
public   void   average_height(){
this.height   =   173.0;
system.out.println( "中国人的平均身高: "+height+ "厘米 ");
}
public   void     average_weight(){
this.weight   =   67.34;
system.out.println( "中国人的平均体重: "+weight+ "公斤 ");
}
}

//定义american_people
class   american_people   extends   people{
public   void   american_boxing(){
system.out.println( "直拳、钩拳 ");
}
public   void   speak_hello(){
system.out.println( "how   do   you   do   ! ");
}
public   void   average_height(){
this.height   =   188.0;
system.out.println( "american   average   height:   "+height+ "   cm ");
}
public   void   average_weight(){
this.weight   =   80.23;
system.out.println( "american   average   weight:   "+weight+ "   kg ");
}
}

//定义beijing_people
class   beijing_people   extends   people{

public   void   beijin_opera(){
system.out.println( "京剧术语 ");
}
public   void   speak_hello(){
system.out.println( "您好 ");
}
public   void   average_height(){
this.height   =   176.0;
system.out.println( "北京人的平均身高: "+height+ "厘米 ");
}
public   void   average_weight(){
this.weight   =   67.0;
system.out.println( "北京人的平均体重: "+weight+ "公斤 ");
}
}

//主类
public   class   people_test   {
        public   static   void   main(string[]   args)   {
                china_people   cp   =   new   china_people();
                american_people   ap   =   new   american_people();
                beijing_people   bp   =   new   beijing_people();
                cp.speak_hello();
                ap.speak_hello();
                bp.speak_hello();
                cp.average_height();
                ap.average_height();
                bp.average_height();
                cp.average_weight();
                ap.average_weight();
                bp.average_weight();
                cp.china_gongfu();
                ap.american_boxing();
                bp.beijin_opera();
        }
}


==========================================================
为什么多次编译有不同的结果??(多次出现,非偶然)
在csdn搜了一下好像很多人都遇到过结果1的情况,请高手解释一下


结果1(错误)
--------------------configuration:   <default> --------------------
java.lang.nosuchmethoderror:   main
exception   in   thread   "main "  
process   completed.

结果2(正确)
--------------------configuration:   <default> --------------------
你好,吃饭了吗
how   do   you   do   !
您好
中国人的平均身高:173.0厘米
american   average   height:   188.0   cm
北京人的平均身高:176.0厘米
中国人的平均体重:67.34公斤
american   average   weight:   80.23   kg
北京人的平均体重:67.0公斤
坐如钟,站如松,睡如弓
直拳、钩拳
京剧术语

process   completed.

=============================================================
如果结果中文出现乱码请先参照下面:
jcreator   4中文设置:
菜单:configure   -->   options   -->   jdk   tools   -->   compiler,选中 <default> ,然后选edit,parameters里面,最前面添加:-encoding   utf-8。
parameters原来的默认值为:-classpath   "$[classpath] "   -d   "$[outputpath] "   $[modjavafiles]
修改后为:
-encoding   utf-8   -classpath   "$[classpath] "   -d   "$[outputpath] "   $[modjavafiles]
发表于:2007-04-19 21:21:581楼 得分:0
请教高手:这真是jcreator4的问题吗??如何解决?
发表于:2007-04-19 22:36:302楼 得分:0
好久没有用过jcreator了。。。lz是不是有时候没有运行people_test这个类,如果运行的是people或者其他的话就会出现结果1的异常。。。
还有类名应该大写,养成良好的编码习惯会减少很多不必要的麻烦~
发表于:2007-04-19 23:12:083楼 得分:0
people_test是主类哦,怎么会没运行??

类名大写是好的习惯吗,也请高手发表一下意见。。。。
发表于:2007-04-20 10:50:304楼 得分:20
不好意思,是类名首字母应该大写,还有方法名首单词小写,第二个单词开始要大写首字母。。。随便一本java教材应该都有提及到。。。
你建立的是不是一个project?如果是project的话点击EXECute   project应该不会出错的,如果不是project的话所EXECute的file必须是people_test,如果你是在people下点击EXECute   file的话就会出现找不到main方法的error~
发表于:2007-04-22 16:30:385楼 得分:0
我建的只是单个文件,没建项目。就因为这个吗?
可怎么有时行,有时不行呢?
唉,搞不懂,过两天就把帖结了。。。。。。


快速检索

最新资讯
热门点击