Java Tutorial - Passing by Value (Object References)

preview_player
Показать описание
Passing by Value (Object References).

In an earlier video, I discussed a common difficulty that every beginner Java programmer encounters - does Java pass primitive data variables (i.e. int, float, char, boolean, etc) to method parameters by value or by reference. Recall Java *always* passes by value (passes a copy) and never by reference (passes the original).

In this video, I explain using examples how Java passes object references by value (that is to say - passes a copy of the object variables, arrays, etc) . In particular, I illustrate in detail how the passing by value of object references can exhibit behavior that is very similar to passing by reference (i.e. passing the original object memory address).

I hope you find this video beneficial. Please leave any comments or feedback in the comments section and I will respond as soon as I can. Thank you.

WATCH SOME MORE JAVA TUTORIALS

Enhanced For Loop Explained and Illustrated

For Loops Explained and Common Pitfalls Highlighted

How to use the Shortcut Operators

How to use the Conditional Operator ( ? : )

Compare Objects - Equality Operator Vs Equals Method

Command Line Arguments

How To Write A Method Part II

How To Write A Method Part I

Passing by Value (Primitive Data Types)

Division and Modulo Operators Explained

Operator Precedence Explained

What are Data Types, Variables and Constants?

How to use Nested If Statements

How to use simple If Statements

What are Control Flow Statements

How to Write, compile and run your first Java program on Windows

How to write, compile and run Java programs all within Notepad++

How to download and install the Notepad++ editor on Windows
Рекомендации по теме
Комментарии
Автор

This 2015 video is better than a number of tutorials in 2021. Thx!!

leiferrrikson
Автор

I have been banging my head to understand this for last hour but you explained it so simply. Now I understand why java is only said to have passing by value.

pratikpatil
Автор

Excellent! I think this is the best explanation given for passing objects as parameters and passing those by value!

romannagel
Автор

this is the best video on youtube. if you can't understand it now, leave programming, leave earth, leave this universe.

itachiuchiha-vsqb
Автор

you have successfully explained what is called passing by reference for decades and then you name it passing by value.
Java is passing by sharing "Thus the behaviour of call by value Java or Visual Basic and call by value C or Pascal are significantly different: in C or Pascal, calling a function with a large structure as an argument will cause the entire structure to be copied and mutations to the structure are invisible to the caller. However, in Java or Visual Basic only the reference to the structure is copied and mutations to the structure are visible to the caller."

martinisdn
Автор

Sir I really appreciate your effort. You made it look so easy. My concept is clear now.
Thanks for making this video!!!

rjjaiswal
Автор

This is a great, great tutorial and explains what it should in the best possible way. It is a shame that you have only couple of tutorials about java and not much more because you could be one of the best java lecturer. Thanks for making this video and of course like, share, subscribe...

ivanpantic
Автор

Martin you explained this so well, very much appreciated!!!

mattchana
Автор

Last 5 minutes of your video exactly explains why we get confused with pass by value and pass by reference in java while dealing with objects. Good job man! Thank you !

akashkotabagi
Автор

Thank you so much!
5 years later and still very helpful!

Aditya-jvmp
Автор

Simple and Clear explanation. Thank you!

teeru
Автор

Thanks for clearing it up, You've done a better job at explaining this than all these other Java tutorials that somehow expect you to understand this stuff automatically.

deezeed
Автор

At last somebody explains it plain and clear!. I read and read about this but never understood it quite clear. Now I realize I had the concept all the way round. Thank you!

yaguarete
Автор

I finally understood without getting confused what this is about. Thank you so much for this.

joanneh
Автор

Excellent explanation, thank you! If you're still making videos and want to expand, I think an in depth video explaining deep copying would be greatly appreciated.

dukkhan
Автор

wow at last I got it. here it is: when passing object types you are not passing the data of the object but the address of the object. so you are passing a copy of the reference address of the object.

ad
Автор

Such a good explanation of this. I was baffled before and now I'm confident I could explain this to someone new. Thanks a ton!

mikeweiss
Автор

The explanation was clear and concise in the best possible way. Well done.

gregaikey
Автор

That visual makes it so much easier to learn!!

youtubeaccountx
Автор

WoW. Thank much. Just learning Java, watched many videos but was more confused with Pass by value and Pass by reference. Your video is OUTSTANDING, CLEAR AND WELL EXPLAINED.

startgrowyouritcareer
visit shbcf.ru