在我QuestionnaireUI.java类“字符串不能转换为整数”
private void btnProceedActionPerformed(java.awt.event.ActionEvent evt) {
tblResults.setRowSelectionAllowed(true);
int temp = tblResults.getSelectedRow();
Global.manu = tblResults.getValueAt(temp, 1).toString();
Global.mod = tblResults.getValueAt(temp, 2).toString();
Global.price = "R" + (Integer)tblResults.getValueAt(temp,3).toString(); //line of code that gives me the error message
this.dispose();
new PaymentUI().setVisible(true);
}
在,我用我所有的全局变量
public class Global {
public static int rowSelect;
public static String manu;
public static String mod;
public static int price;
public static int financeprice;
public static int rate = 9;
}
后的Java 5'的ToString ()'是不需要的,因为自动装箱会将其转换为字符串... –
如何将R'转换为int? – Jens
BTW:属性不应公开。你应该让他们私密,并通过getter和setter访问 – Jens