从main调用的数组

时间:2014-07-20 01:58:42

标签: java arrays call

我有以下代码,我想在main方法中调用printArray,以便它可以打印。我一直收到以下错误:

  

无法找到符号             int[] arrays = new int[randomNumbers];

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);

    System.out.print("How many random ints?");
    int randomNumbers = input.nextInt();

    System.out.print("What is the lower bound?");
    int lower = input.nextInt();

    System.out.print("What is the upper bound?");
    int upper = input.nextInt();

    int range = (upper - lower) + 1;
    printArray(); //not working
}

public static void printArray(int[] array) {
    int[] arrays = new int[randomNumbers];

    for (int t = 0; t < array.length; t++) {
        System.out.print("arr[" + t + "] :" + array[t]);
    }

    System.out.println();
}

非常感谢任何帮助。

0 个答案:

没有答案