Beginner at Java, need an explanation for an answer please : 
    void f(int[] x, int[] y, int p, int q) {
        for (int i=0;i<x.length;++i) {
            x[i] = 2*x[i];
        }
        x=new int[5];
        for (int i=0;i<5;++i) {
            x[i]=0;
        }
        y[3]=5;
        p=q+1;
    }
    void g() {
        int[] x={1,2,3,4};
        int[] y={9,7,6,5};
        f(y, x, y[0], x[0]);
        for (int p:x) {
            System.out.print(""+p+" ");
        }
        for (int q:y) {
            System.out.print(""+q+" ");
        }
        System.out.println();
    }

So If g() is called I know the answer is 1 2 3 5 18 14 12 10, but I have no idea why thats the answer, how p and q even come into the equation is confusing me.