小编use*_*791的帖子

如何在java中调用带数组参数的方法?

我有一个赋值,我必须在Java中对数组执行操作,我必须为每个操作创建单独的函数,我将编写但我无法弄清楚如何使用数组参数调用方法.我通常使用c ++编程,但这个任务是在java中.如果有人能帮助我,我会非常感激.:)

public class HelloJava {
    static void inpoot() {
        Scanner input = new Scanner(System.in);
        int[] numbers = new int[10];

        System.out.println("Please enter 10 numbers ");
        for (int i = 0; i < numbers.length; i++) {
            numbers[i] = input.nextInt();
        }
    }

    static void outpoot(int[] numbers) {
        for(int i = 0; i < numbers.length; i++) { 
                System.out.println(numbers[i]); 
        }
    }

    public static void main(String[] args) {
        inpoot();
        outpoot(numbers); //can not find the symbol
    }
}
Run Code Online (Sandbox Code Playgroud)

java arrays methods invocation

3
推荐指数
1
解决办法
8万
查看次数

标签 统计

arrays ×1

invocation ×1

java ×1

methods ×1