8.6: Pass by Value vs. Pass by Reference - Processing Tutorial

8.6: Pass by Value vs. Pass by Reference - Processing Tutorial

The Coding Train

8 лет назад

229,054 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Dominic Balloch
Dominic Balloch - 04.09.2023 18:45

This concept is very confusing to explain, especially to trainee devs even now being a senior dev for a fairly long time.
Basically, there is no such thing in Java as pass-by-reference. As already pointed out, the primitive explanation is correct. Primitives reside on the stack. A copy of the value is passed to the method param and cannot be changed. 
Objects are stored in the heap. When the object reference is passed to the method param a copy is made on the stack which points to the same location to the original object on the heap. Therefore you can change the attributes of the object but the original version (memory reference) is not actually being changed, if that makes sense. Both references are just pointing to the data (values), its these values that are actually getting passed using pointers.

Ответить
Sorry, I'm Now Coding
Sorry, I'm Now Coding - 11.04.2023 19:26

this is a wrong knowledge !!

Ответить
Shane Detsch
Shane Detsch - 29.03.2023 04:21

aP = new Particle ( x, y ); would be a good addition to this review showing the pass by value nature of Java

Ответить
Anthony Rojas
Anthony Rojas - 03.02.2023 23:48

Made good points, but next time be prepapred. Making shit up as you go is pure laziness.

Ответить
Noble Absinthe
Noble Absinthe - 03.02.2023 07:02

Pass by value (using primitives) you make a copy, and that is what gets messed with, without affecting the original.
Pass by ref(using objects) you are messing with the object itself because it isn't being copied.

You could use a copy constructor to make a "clone" of an object and mess with that one while preserving the original.

Ответить
Resai17
Resai17 - 10.11.2022 16:22

Best video to clearly differentiate between PbV & PbR. Great work!

Ответить
Alisha
Alisha - 20.10.2022 21:03

Thank you

Ответить
Evana Hannah
Evana Hannah - 29.08.2022 15:34

Thank you so much, bearded Harry Potter 😃❤

Ответить
Smita Agawane
Smita Agawane - 06.07.2022 08:35

Your a great teacher ever. Thank you so much for your efforts. 🏆🏆🏆🏆🏆

Ответить
apple smith
apple smith - 17.06.2022 02:23

This is indeed one of the most clear and helpful tutorials that explain the difference between pass by value and pass by reference. Well done!

Ответить
Saltanat Kokzhalova
Saltanat Kokzhalova - 01.06.2022 19:35

Finally, understood the difference between passing by value and passing by reference. Great content.

Ответить
Stay Young With Anastasia
Stay Young With Anastasia - 11.05.2022 01:49

Oh my god. you explain so well

Ответить
qtSoph
qtSoph - 15.02.2022 02:03

thank you so freaking much

Ответить
Brad Weir
Brad Weir - 06.02.2022 20:42

I feel like understanding value and reference types are fundamental to a programmer's understanding of async and multithreaded code. I find that programmers are often told not to use pass by reference without being explained it's to safely avoid bad habits in the future when passing by reference could lead to race conditions and non-threadsafe code.

Ответить
Piotr Jażdżyk
Piotr Jażdżyk - 18.01.2022 23:23

This is The Professor!

Ответить
John Simon
John Simon - 20.12.2021 16:54

Don't listen to this guy

Ответить
Harshal Waghmare
Harshal Waghmare - 07.12.2021 06:52

Heyy youuuu i just wanna thanks to you 🥺 my Mind is going to brust bcz of this concept but not after this video🌻

Ответить
Tarık Mengüç
Tarık Mengüç - 18.10.2021 13:12

Thank you 3 years and you did not fix it yet. You are making it frustrating to people who want to learn more.! Such a thoughtful person.

Ответить
Raillan_off l v2
Raillan_off l v2 - 03.09.2021 04:57

Thank you so much

Ответить
ankita sharma
ankita sharma - 31.08.2021 13:27

omg!! amazing it was..

Ответить
Oorschot
Oorschot - 08.08.2021 00:46

Can't seem to find anywhere what "change()" does.. Can someone help?

Ответить
TORUS
TORUS - 07.06.2021 17:29

His smiling nature is enough to understand things

Ответить
youmils03
youmils03 - 10.05.2021 22:14

Pass by value is so annoying! Pass by reference is so much more intuitive

Ответить
Cornello
Cornello - 15.04.2021 18:18

This video should be updated.

Ответить
ᴀɴᴜʀɪᴛ ʙᴀɢ
ᴀɴᴜʀɪᴛ ʙᴀɢ - 04.04.2021 18:02

Can we use &p instead of ap?

Ответить
helloWorld
helloWorld - 26.02.2021 08:14

Thank you nong!!

Ответить
Vladan Milosevic
Vladan Milosevic - 19.02.2021 11:52

int x=10;
int y;
y=x;
print x;
----------------
x=10
pass by ref.

Ответить
amr elhadidy
amr elhadidy - 06.02.2021 22:01

ty <3

Ответить
Johan picocrie
Johan picocrie - 02.01.2021 18:58

Hallo is There a site were i van download these sketches?

Ответить
A. N.
A. N. - 12.12.2020 16:01

aP will point to P and not to underlying value so far i know

Ответить
Sievny Thav
Sievny Thav - 23.11.2020 10:09

This guy looks like the professor from Money Heist

Ответить
DYSLEXIC_NEURON
DYSLEXIC_NEURON - 30.10.2020 14:19

WTF why did everyone knew java as both pass by reference and pass by value earlier and later in life realized that its always pass by value !! :D

Ответить
Queen Kaine
Queen Kaine - 30.10.2020 08:16

Can someone help me with thus please


A method that takes an array of double. Return whether or not every element in the array appears in ascending order, begining with the SECOND element AND if the first element is equal to the sum of all elements beginning with the second element. You must use 1 loop at the most for this and recall the difficulty of checking equality with doubles that may contain math error.

Ответить
ian
ian - 11.10.2020 16:23

you look like you planning to rob a bank. bank of spain, perhaps? kiddin, thank u for this

Ответить
Saurav Singh
Saurav Singh - 16.06.2020 07:49

If he bit changed, He will look like Professor from Money Heist

Ответить
SAI ASHWIN KUMAR C
SAI ASHWIN KUMAR C - 03.06.2020 11:09

there's no pointers concept in java?

Ответить
Colorful Codes
Colorful Codes - 02.06.2020 05:51

You are an amazing teacher!

Ответить
Rebecca Haokip
Rebecca Haokip - 25.05.2020 21:00

Lol make sense... after watching it again ... after 1 year

Ответить
Aziz Kerimkulov
Aziz Kerimkulov - 11.05.2020 05:43

Worst explanation ever

Ответить
Flashy Virtouso
Flashy Virtouso - 03.05.2020 05:34

This is a tricky concept when you are learning programming languages like c ,etc,3 pages of gibberish text from the book solve ,hope you tube was there back in the 90's learning programming could be fun...thanks master!!!!

Ответить
Farooq Awan
Farooq Awan - 18.02.2020 18:02

Thank you

Ответить
luffy
luffy - 24.01.2020 23:13

Thank you

Ответить
Annalise Trite
Annalise Trite - 08.01.2020 02:35

When I play around with this concept it doesn't seem to apply to String or BigInteger...could someone explain why?

Ответить
Annalise Trite
Annalise Trite - 08.01.2020 02:01

Fantastic explanation, thank you!

Ответить
Samir G
Samir G - 17.12.2019 13:08

aP → uP 😎👍

Ответить
Scott Anderson
Scott Anderson - 23.11.2019 21:28

say what?

Ответить
juan manuel Millan Sanchez
juan manuel Millan Sanchez - 22.11.2019 21:49

This video has been very usefull for me thanks u man !

Ответить