so i was given this question in class.
consider the following method declaration:
public static int method(int[] x)
Is the int[] x parameter passed by reference or by value?
To my understanding only primitives can be passed by value. This therefore is passed by reference? I read from here (Are arrays passed by value or passed by reference in Java?) that 'java can only pass by value' and that the reference pointing to the object array x is being passed as a value.
so what is the answer? Is the int[] x parameter passed by reference or by value?
Can someone also give me an example of a pass by reference since java can't do this?
many thanks
Everything in Java is pass-by-value. Consider your function: