hello,
I have this question to ask from you...
when passing a object to a method is it pass by reference or pass by value ? I'm talking about calling another class's method...
hello,
I have this question to ask from you...
when passing a object to a method is it pass by reference or pass by value ? I'm talking about calling another class's method...
In java, objects, arrays and strings are always passed by reference. Only primitive types (byte, char, int, long) are passed by value.
In java, objects, arrays and strings are always passed by reference. Only primitive types (byte, char, int, long) are passed by value.
thanks
That's right. Java is only pass by value, regardless of whether parameters are primitive types or reference types.
When the method or constructor is invoked (ยง15.12), the values of the actual argument expressions initialize newly created parameter variables, each of the declared Type, before execution of the body of the method or constructor.
Java Language Specification section 8.4.1
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.