これはメインクラスにあります
actionsClass actionObject = new actionsClass(tipArray, hourArray,
hourlyWageInput, gasArray, wageArray, incomeArray, totalHourlyEarnings,
totalGas, totalHours, avgGasLabel);
actionObject.calculateTable();
これは、メソッドを実装しようとしているクラスです (現在、過剰に宣言された変数があります)。
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class actionsClass {
private JLabel hourlyWage, blank, row2, totalTips, totalHours, totalHourlyEarnings,
totalPay, weekPay, day, totalGas, totalHoursLabel, totalTipsLabel, totalGasLabel,
totalWageLabel, avgGas, avgGasLabel;
private JTextField hourlyWageInput;
private double incomeArray[] = new double[7];
private JTextField tipArray[] = new JTextField[7];
private JTextField hourArray[] = new JTextField[7];
private JTextField gasArray[]= new JTextField[7];
private JLabel wageArray[] =new JLabel[7];
public actionsClass() {
}
public actionsClass(JTextField[] tipArray, JTextField[] hourArray,
JTextField hourlyWageInput, JTextField[] gasArray,
JLabel[] wageArray, double[] incomeArray,
JLabel totalHourlyEarnings, JLabel totalGas, JLabel totalHours,
JLabel avgGasLabel) {
this.tipArray = tipArray;
this.hourArray = hourArray;
this.hourlyWageInput = hourlyWageInput;
this.gasArray = gasArray;
this.wageArray = wageArray;
this.incomeArray = incomeArray;
this.totalHourlyEarnings = totalHourlyEarnings;
this.totalGas = totalGas;
this.totalHours = totalHours;
this.avgGasLabel = avgGasLabel;
}
public String calculateTable (){
for (int i = 0; i < 7; i++) {
double tipx = Double.parseDouble(tipArray[i].getText());
double houry = Double.parseDouble(hourArray[i].getText());
double hourlyz = Double.parseDouble(hourlyWageInput.getText());
String[] wageArrayStrings = null;
if (houry != 0 ){
wageArrayStrings[i] = String.format("%.2f", (hourlyz*houry+tipx)/houry);
}
else {
wageArrayStrings[i] = ("$ 0.00");
}
}
return wageArrayStrings[];
}
}
戻り値 wageArrayStrings[]; に構文エラーがあります。ブラケットの有無にかかわらず。私は何を間違っていますか?