Answer the question
In order to leave comments, you need to log in
About links in Java. How do they work?
MyObject ie = new MyObject( );
I have created an object MyObject.
ie is now a link? I can't exactly formulate the question, but I clearly don't understand something. In C++, this is somehow easier.
As Sedgwick writes, in Java, in arrays, we pass references to objects, and not the objects themselves. And how can the object itself be passed, and which reference to it?
Answer the question
In order to leave comments, you need to log in
The object itself is in memory, and all variables store a reference to the object. Here, on the contrary, it is easier in java, because there is no possibility of passing the objects themselves, only links.
And in C++, I can create a variable that refers to an object, I can create a variable that refers to the area of memory where the object is stored, I can create a reference to a variable that stores a reference to an object that is stored in memory. And I have to allocate and clean up the memory myself, so in C++ it's possible to pass a reference to an object in memory that doesn't exist anymore, and if you use it, you'll shoot yourself in the foot with a segmentation fault. Something like this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question