-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