Java Developers
Group for Java developers and programmers. Ask questions and get answers related to Java programming
263 Members
Join this group to post and comment.
Gaurav Prasad
Gaurav Prasad
Computer Science
19 Jan 2019

Java is Pass by Value or Pass by Reference?


Information Technology
3mos ago

When you program all methods and local variables exist in a junk of memory that the JVM reserves that is called the stack. Each method which is called is separated by frame  in stack. That means each method is stored like a different island in stack. The only way this methods communicate is through the parameters and return statements. While calling a method we need to pass parameters. There are two way to pass parameters 

1)  one method passes arguments to other method and other method makes a copy of it. This is pass by value.

2)One method passes the address to other method and other method accesses the variable directly through address. This is pass by reference.

Java is pass by value but because of the way the work objects functions closer to pass by reference.