
WobblyBurrito
11moby
Does java use call by value or reference for objects?
Value
Reference
26 votesexpired
11mo ago

SquishyBoba
11mo
Java always uses call by value — but it can be confusing because of how it handles objects and primitives.
Breakdown: 1. Primitives (int, float, etc.): Java passes a copy of the value. Changes inside the method don’t affect the original variable. 2. Objects (including arrays): Java passes a copy of the reference (pointer) to the object, not the actual object itself. • You can modify the object’s internal state (fields) inside the method. • You cannot reassign the reference inside the method and expect it to change the caller’s reference.

WobblyBurrito
11mo
Exactly
Discover more
Curated from across