Developer community
0 votes
174 views
asked by Geek (15.3k points) 19 43 68 | 174 views

1 Answer

0 votes
Primitive variables are passed by value.
reference variables are passed by reference.
When you pass a primitive variable, the JVM will copy the value of the passed-in variable to a new local variable.
If you change the value of the local variable, the change will not affect the passed in primitive variable.
If you pass a reference variable, the local variable will refer to the same object as the passed in reference variable.
If you change the object referenced within your method, the change will also be reflected in the calling code
answered by Expert (11.4k points) 16 23 32

Related questions

0 votes
1 answer
asked by smith Geek (15.3k points) 19 43 68 | 96 views
0 votes
1 answer
asked by john Guru (27.1k points) 35 52 113 | 21 views
0 votes
1 answer
asked by smith Geek (15.3k points) 19 43 68 | 19 views
+1 vote
3 answers
0 votes
3 answers
asked by sara Guru (24.6k points) 31 57 92 | 37 views
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

3,754 questions
4,046 answers
117 comments
10,709 users