所以我查看了许多其他标识符预期的答案,但它们似乎不合适。我的主类中有完整的代码,但主方法中没有。我觉得我只是错过了一些简单的东西。
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
}
最佳答案
刚刚意识到我没有正确识别参数,没有列出 [] 名称。正在寻找问题删除选项。
关于java - 标识符预期错误(不是通常的答案),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43479477/