---
title: "What is Java,\"pass-by-reference\" or \"pass-by-value\"?"  
description: "What is Java,\"pass-by-reference\" or \"pass-by-value\"?"  
author: "Utpal Vishwas"  
published: 2023-07-21  
updated: 2023-11-17  
canonical: https://www.mindstick.com/forum/159208/what-is-java-pass-by-reference-or-pass-by-value  
category: "java"  
tags: ["java"]  
reading_time: 2 minutes  

---

# What is Java,"pass-by-reference" or "pass-by-value"?

What is [Java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming),"pass-by-[reference](https://www.mindstick.com/forum/774/reference-what-does-this-error-mean-in-php)" or "pass-by-[value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages)"?

## Replies

### Reply by Aryan Kumar

In Java, the concept of "pass by value" is often discussed in the context of method parameter passing. Java uses pass by value for all method arguments, but it's essential to understand what "pass by value" means in the context of primitive types and reference types.

## Pass by Value for Primitive Types:

- When you pass a primitive type (e.g., **int**, **float**, **char**) to a method in Java, you are passing the actual value of the variable. Any changes made to the parameter inside the method do not affect the original variable outside the method.

## Pass by Value for Reference Types:

- When you pass a reference type (e.g., objects, arrays) to a method in Java, you are passing the value of the reference, not the actual object. This can be a source of confusion, as changes made to the object's state inside the method are visible outside the method.

In summary, Java is strictly "pass by value," but for reference types, what is being passed is the value of the reference (memory address), not the actual object. This means changes made to the state of the object (if it is mutable) are visible outside the method. Understanding this distinction is crucial for writing robust and predictable Java code.


---

Original Source: https://www.mindstick.com/forum/159208/what-is-java-pass-by-reference-or-pass-by-value

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
