我正在使用进行赋值的方法,但我无法通过getBidAmounts
方法。我不断收到这种错误:
required: int[],int found: int[] reason: actual and formal argument lists differ in length
。
public static void main (String[] args) {
double budget = getBudget();
final double MIN_BID_AMOUNT = 0;
final int MIN_NUM_BIDS = 0;
final int MAX_NUM_BIDS = 100;
int numBids = getNumBids(MIN_NUM_BIDS, MAX_NUM_BIDS);
int[] bids = new int[numBids];
getBidAmounts(bids);
}
public static void getBidAmounts (int[] bidAmounts, int minBidAmount) {
for (int i = 0; i < bidAmounts.length; i++) {
do {
bidAmounts[i] = Integer.parseInt(JOptionPane.showInputDialog("Enter the Amount of Bid #" + (i+1) + ": "));
if (bidAmounts[i] <= minBidAmount)
{
JOptionPane.showMessageDialog(null, "Enter a Valid Bid Amount Above" + minBidAmount + ".");
}
} while (bidAmounts[i] <= minBidAmount);
}
}
这应该允许用户将事物输入到数组中。
答案 0 :(得分:0)
调用getBidAmounts(bids);
时,您只提供一个参数,而
public static void getBidAmounts (int[] bidAmounts, int minBidAmount)
需要两个参数。
因此,将由getBidAmounts(bids);
更改为getBidAmounts(bids,
MIN_NUM_BIDS
);
。
在这里,MIN_NUM_BIDS
将表示minBidAmount
方法内的参数getBidAmounts
(第二个)。