声明一个新的空对象我创建了一个类,并把它命名为“PaymentObject”我如何在androidStudio
public class PaymentObject implements Serializable {
double precentsValue;
String PrecentsText;
@Override
public String toString() {
return PrecentsText;
}
public PaymentObject(String paymenttext,double paymentvalue)
{
this.PrecentsText=paymenttext;
this.precentsValue=paymentvalue;
}
public String getPrecentsText(){return PrecentsText;}
public void setPrecentsText(String percents){this.PrecentsText=percents;}
public double getPrecentsValue(){return precentsValue;}
public void setPrecentsValue(double percentsvalue) {this.precentsValue=percentsvalue;}
}
在我的MainActivity类别我想初始化PaymentObject类型 的新空对象,然后设置值给对象。 这样的:
PaymentObject po = new PaymentObject();
po.setPrecentsValue(1);
po.setPrecentsText("100%");
,但是当我这样做还有一个错误“在PaymentObject PaymentObject(字符串,双)不能适用于()” (全髋关节置换工作,只有当我添加的值时,我声明对新对象) 但我想打开一个空对象,然后设置值... 我该怎么办? 谢谢!