所以我查看了许多其他标识符的预期答案,但它们似乎不合适。我在我的主类中有完整的代码,但不是在我的main方法中。我觉得我只是缺少一些简单的东西。
import java.util.Arrays;
import java.util.Scanner;
import java.util.Random;
public class L7C14
{
public void QuickSort(int[], int min, int max)//this is where Im getting the ID error. I placed it at the top for Q/A purposes. quick sort is just supposed to be another method in my class L7C14.
{
int middle = min + ( (max-min) /2);//not finished with code logic in here
}
public static void main(String[] args)
{
Random rand = new Random();
int[] nums = new int[10];
Scanner input = new Scanner(System.in);
System.out.println("please make a selection: Would you like to input 10 numbers (1) or randomly generate them (2)");
if(input.nextInt()==1)
{
for (int i = 0; i < nums.length; i++)
{
System.out.println("Number "+(i+1)+"?");
nums[i] = input.nextInt();
}
}
else
{
for (int i = 0; i < nums.length; i++)
{
nums[i] = rand.nextInt(648);
}
}
//now the array is fully populated
//display numbers[]
System.out.println("Your numbers are");
System.out.println(Arrays.toString(nums));
/* I think this looks better
for (int i = 0; i < nums.length; i++)
{
System.out.print("\n"+nums[i]);
}
*/
}
//now sort lowest to highest, display
//sort highest to lowest, display
}
答案 0 :(得分:1)
刚刚意识到我没有正确识别参数,没有列出[]名称。寻找问题删除选项。