在我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