public String toString(){
String info=new String();
if(this.getReal()==0)
info=this.getImage()+"i";
else if(this.getReal()==0)
info=this.getReal();这里有错
else if(this.getImage()<0)
info=this.getReal()+this.getReal()+"i";
else
info=this.getReal()+"-"+this.getReal()+"i";
return info;
}
第六行有错,但是我不知道是什么错误?有谁帮我指出来啊。还有,上面的info=this.getImage()+"i";是正确的而info=this.getImage()+'i';是错误的,为什么?
String info=new String();
if(this.getReal()==0)
info=this.getImage()+"i";
else if(this.getReal()==0)
info=this.getReal();这里有错
else if(this.getImage()<0)
info=this.getReal()+this.getReal()+"i";
else
info=this.getReal()+"-"+this.getReal()+"i";
return info;
}
第六行有错,但是我不知道是什么错误?有谁帮我指出来啊。还有,上面的info=this.getImage()+"i";是正确的而info=this.getImage()+'i';是错误的,为什么?
String info=new String();if(this.getReal()==0){
info=this.getImage()+"i";
}
else if(this.getReal()==0){
info=this.getReal();//你把一个int或Integer型(this.getReal()==0,根据此得出其数据类型)的数据赋给了Stirng,数据类型不一致;修改成info=this.getReal().toStirng();
}
else if(this.getImage()<0){
info=this.getReal()+this.getReal()+"i";
}
else{
info=this.getReal()+"-"+this.getReal()+"i";
}
return info;
}
info=this.getImage()+"i";
}else if(this.getReal()==0){
info=this.getReal
}去掉上述两个分支中的一个(重复了)。
public String toString(){
String info=new String();
if(this.getReal()==0)
info=this.getImage()+"i";
else if(this.getImage()==0)
info=this.getReal()+"I";
else if(this.getImage()<0)
info=(this.getReal()).toString()+(this.getImage()).toString()+"i";
else
info=this.getReal()+this.getImage()+"i"+5;
return info;
}
错误在第9行,就是我按你的改法修改后提示的“无法取消应用 double”
改为
String.valueOf(this.getReal())