BBS水木清华站∶精华区
发信人: KHP (人之初), 信区: Java
标 题: Re: help!
发信站: BBS 水木清华站 (Sat May 29 01:57:19 1999)
如果这是一个文件当然不行了,每个文件中只能有一个 public 类,
import 在所有类定义之前
【 在 xianfeng (风云) 的大作中提到: 】
∶ 我是一个java的初学者下面的程序编译时出错
∶ 小弟不得其解 望各位仁兄相助
∶ **为出错处和其提示
∶ //Testcomp.java
∶ //define a class of complex
∶ public class Complex1 **”Complex1" with a red line
∶ {
∶ private float real; //the real part of the Complex
∶ private float imag; //the imaginary part of the Complex
∶ :
∶ :
∶ public String toString()
∶ {
∶ return ( "(" + real + "," + imag + ")" );
∶ }
∶ }
∶ //test the function of the class 'Complex1'
∶ //import Complex1;
∶ import java.awt.Graphics; **"import with a red line "
∶ **error "Expected 'class','interface',or 'delegate'(j0256)"
∶
∶ import java.applet.Applet;
∶ public class Testcomp extends Applet
∶ {
∶ private Complex1 com1 = new Complex1(3, 5 );
∶ private Complex1 com2 = new Complex1(2, 4 );
∶ :
∶ :
∶ }
--
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 166.111.163.77]
BBS水木清华站∶精华区