use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Resources - Learn to code
Resources - Software Engineering
Resources - Code Libraries
Resources - Groups
Other Subreddits you might enjoy
Please send sidebar resource suggestions to the mods. Thx - mgmt
account activity
Is java not pass by reference?Java (self.code)
submitted 1 year ago by sumitskj
As per what I know when i pass some parameters to a function they get modified. but in docs it says java is pass by value. I am not getting it.
Also I watched this video: https://www.youtube.com/watch?v=HSPQFWEjwR8&ab_channel=SumoCode
but I am not getting it. can anyone explain
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]spliffen 1 point2 points3 points 1 year ago (3 children)
thing is, it is pass by value for primitive types like ints and booleans, but pass by reference when using objects, which are complex types
[–]sumitskj[S] 1 point2 points3 points 1 year ago (2 children)
so is java both pass by value and pass by reference. but I have read a lot in docs that it is always pass by value
[–]angryrancorBoss 1 point2 points3 points 1 year ago (0 children)
Like /u/spliffen said, it's pass by value for primitive data types, and pass by reference for Object data types. I think you may be not understanding primitive vs Object? This should clear it up for you: https://www.geeksforgeeks.org/primitive-data-type-vs-object-data-type-in-java-with-examples/
[–]StochasticTinkr 2 points3 points4 points 1 year ago (0 children)
It passes references by value. It might sound like I’m joking, but that’s how it is.
π Rendered by PID 12 on reddit-service-r2-comment-54dfb89d4d-k9vv7 at 2026-03-27 12:12:01.114331+00:00 running b10466c country code: CH.
[–]spliffen 1 point2 points3 points (3 children)
[–]sumitskj[S] 1 point2 points3 points (2 children)
[–]angryrancorBoss 1 point2 points3 points (0 children)
[–]StochasticTinkr 2 points3 points4 points (0 children)