Does Java Ever Pass by Reference?

preview_player
Показать описание
A discussion of Java parameter passing with demonmstrations of what java is really doing with objects: passing the reference by value.
Рекомендации по теме
Комментарии
Автор

@10:25 Sorry, I think I missed the core point. Passing a reference by value = passing memory adrdess ? what is passing by reference? I do not understand this statement . (in c++ pass by reference is done to change the value)

croydonH
Автор

Hello, is the change reference before null garbage collected when calling change reference after main account is set to null?

croydonH
Автор

Hello Dr Califf.

Could you consider Java to be weakly typed language since if you create an object, you can change its datatype to one of its child class?

For example if you have a object x, you can change it to a Integer object later down in the class, but also change it to a different object again later in the class.

Of course you cannot do this with primitives, only with classes that have child classes.

This is an example code that works, and shows that weak typing can exist in java.

Object x = new Object();

System.out.println(x);

x = new Integer(5);
// changed typing to integer
System.out.println(x);
x = new Double(5.0);
// changed typing again to double
System.out.println(x);

Thank you,
Mike Xie.

mxie
Автор

I enjoy your videos. That being said, then what does "pass by reference" mean if not passing the value of the reference? Is it more like pointers from c++?

Rockyzach