0

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...

4
Contributors
4
Replies
7
Views
5 Years
Discussion Span
Last Post by JamesCherrill
Featured Replies
  • That's right. Java is only pass by value, regardless of whether parameters are primitive types or reference types. [QUOTE]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 … Read More

0

In java, objects, arrays and strings are always passed by reference. Only primitive types (byte, char, int, long) are passed by value.

0

In java, objects, arrays and strings are always passed by reference. Only primitive types (byte, char, int, long) are passed by value.

thanks

1

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.