萍聚社区-德国热线-德国实用信息网

 找回密码
 注册

微信登录

微信扫一扫,快速登录

萍聚头条

查看: 640|回复: 0

1-1-4-6 一个文件里可以申明几个类

[复制链接]
发表于 2003-2-5 13:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册 微信登录

x
发信人: KHP (人之初), 信区: Java      
标  题: Re: help!
发信站: BBS 水木清华站 (Sat May 29 01:57:19 1999)


如果这是一个文件当然不行了,每个文件中只能有一个 public 类,
import 在所有类定义之前

【 在 xianfeng (风云) 的大作中提到: 】
: 我是一个java的初学者下面的程序编译时出错
: 小弟不得其解 望各位仁兄相助
: **为出错处和其提示

  1. : //Testcomp.java
  2. : //define a class of complex
  3. : public class Complex1     **”Complex1" with a red line
  4. : {
  5. :         private float real; //the real part of the Complex
  6. :         private float imag;     //the imaginary part of the Complex
  7. :                 :
  8. :                 :
  9. :         public String toString()
  10. :         {
  11. :                 return ( "(" + real + "," + imag + ")" );
  12. :         }
  13. : }
  14. : //test the function of the class 'Complex1'
  15. : //import Complex1;
  16. : import java.awt.Graphics; **"import with a red line "
  17. :     **error "Expected 'class','interface',or 'delegate'(j0256)"
  18. :                                            
  19. : import java.applet.Applet;
  20. : public class Testcomp extends Applet
  21. : {
  22. :         private Complex1 com1 = new  Complex1(3, 5 );
  23. :         private Complex1 com2 = new  Complex1(2, 4 );
  24. :         :
  25. :         :
  26. : }
复制代码
Die von den Nutzern eingestellten Information und Meinungen sind nicht eigene Informationen und Meinungen der DOLC GmbH.
您需要登录后才可以回帖 登录 | 注册 微信登录

本版积分规则

手机版|Archiver|AGB|Impressum|Datenschutzerklärung|萍聚社区-德国热线-德国实用信息网 |网站地图

GMT+2, 2024-5-21 20:41 , Processed in 0.052169 second(s), 18 queries , MemCached On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表