看一下Complex.class文件是否在当前目录下
或者是你在其中定义了包

解决方案 »

  1.   

    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.IOException;public class Complex
    {
    float realPart;
    float imagePart; Complex(){realPart=0;imagePart=0;} //构造函数一 Complex(float real,float image) //构造函数
    {
    realPart=real;
    imagePart=image;
    } public void showMe()
    {
    System.out.print(this.realPart);
    if(this.imagePart==0)
    System.out.print("");
    else if(this.imagePart>0)
    {
    System.out.print("+");
    System.out.print(this.imagePart);
    System.out.print("i");
    }
    else
    {
    System.out.print(this.imagePart);
    System.out.print("i");
    }
    }
    public Complex add(Complex A,Complex B) //两个复数相加
    {
    Complex C=new Complex();
    C.realPart=A.realPart+B.realPart;
    C.imagePart=A.imagePart+B.imagePart;
    return C;
    } public Complex sub(Complex A,Complex B)
    {
    Complex C=new Complex();
    C.realPart=A.realPart-B.realPart;
    C.imagePart=A.imagePart-B.imagePart;
    return C;
    } public Complex mul(Complex A,Complex B)
    {
    Complex C=new Complex();
    C.realPart=A.realPart*B.realPart-A.imagePart*B.imagePart;
    C.imagePart=A.realPart*B.imagePart+A.imagePart*B.realPart;
    return C;
    } public static void main(String args[])
    {
    float real=0,image=0;
    Complex C1,C2;
    BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("请输入复数C1的实部:");
    try
    {
    real=Float.parseFloat(reader.readLine());
    }
    catch(IOException e){}
    System.out.println("请输入复数C1的虚部:");
    try
    {
    image=Float.parseFloat(reader.readLine());
    }
    catch(IOException e){}
    C1=new Complex(real,image); System.out.println("请输入复数C2的实部:");
    try
    {
    real=Float.parseFloat(reader.readLine());
    }
    catch(IOException e){}
    System.out.println("请输入复数C2的虚部:");
    try
    {
    image=Float.parseFloat(reader.readLine());
    }
    catch(IOException e){}
    C2=new Complex(real,image); System.out.println("C1=");
    C1.showMe();
    System.out.println("C2=");
    C2.showMe();
    }
    }
      

  2.   

    zijibense(自己本色):
    这个贴子不用回复了,我已找到问题,把当前目录“.”加进ClassPath就行了。虽然 zijibense(自己本色)没回复什么,但他叫我把代码贴出来,这份热心难得。