-2
我是新來的Java ans與數組掙扎。我需要數組代碼的幫助。有20個錯誤,但我似乎無法找到它們(除了7)。另外,我是StackOverflow的新手,對於格式很抱歉。 代碼是:Java-陣列錯誤
public clas ArrayProcessing
{
public void main (String [] args)
{
int iElement = 0,
int iSmallest = 0,
int iPossible = 0;
String strElements, strSmallest, strPossibles = "";
strElements = joptionPane.showInputDialog("How many elements would you like to be included in the array?");
iElements= Integer.parseInt(strElements);
strSmallest =joptionPane.showInputDialog("What would you like the smallest number in the array to be?");
iSmallest = Integer.parseInt(strSmallest);
strPossibles = joptionPane.showInputDialog("How many possible unique numbers would you like to have?");
iPossibleS= Integer.parseInt(strPossible);
int[] intArray = int[iElement];
displayArray(intArray[0]);
loadArray(intArray, iSmallest, iPossbles)
displayArray(intArray);
}
public static void loadArray(int intArray, int iSmallest, int iPossibles)
{
for (index =0; index < intArray.length(); index++)
{
intArray[index] = iSmallest + (int) (Math.random()* iPossibles);
}
}
public void displayArray(int[] intArray)
{
String strOutput="";
for (iCounter = 0, iCounter<intArray.length, iCounter++);
{
Output += intArray[iCounter] + "";
}
jOptionPane.showMessageDialog(null, "These are the values in your array: \n" + strOutput, "Arrays", JOptionPane.INFORMATION_MESSAGE);
}
http://stackoverflow.com/editing-help – azurefrog
你有沒有聽說過縮進?你知道,使代碼可讀的概念? – Andreas
因爲'intArray'是一個*數組*,所以'loadArray'參數中'int intArray'改爲'int [] intArray'會有幫助嗎? ---由於你的第一個'for'循環在部件之間正確使用';',你爲什麼要在第二個部件中使用'''? – Andreas