Hello.
Why this doesn't work?
import java.lang.System;
out.println("Hola mundo");
Sorry I can't post the full code, but I'm on my cell phone.
Thank you very much.
Hello.
Why this doesn't work?
import java.lang.System;
out.println("Hola mundo");
Sorry I can't post the full code, but I'm on my cell phone.
Thank you very much.
As I understand it, when creating a variable, we are creating an object, and the name of the variable refers to it.
If I do:
a = 2
a = "Hola"
The garbage collector takes care of deleting object 2, since it doesn't need it and no other variable is referencing it in the program. Instead if I write:
a = 2
b = a
a = "Hola"
Since b is referencing object 2, I now have both objects in memory, and neither is deleted.
I am right? Thank you very much.
I have a doubt with the endl
stream handler function.
According to the book I'm reading (Deitel), it flushes endl
the output buffer.
What does this mean? Since if I put "\n"
or std::endl
at the end cout
I receive the same output.
Is there a way to be able to see the difference?
I'm learning Java and I have a question about data types.
A variable of primitive type stores a single value. When I assign a new one to it, the old value is lost.
Now with the variables by reference I propose an example, I have a class called Auto
, with an instance variable, called Color
.
If I create two objects of that class, they would both point to "the same" in memory, but each would hold a separate copy of the instance variable, so I can change the Color value on one object, without affecting the other. . However, if I destroy the object, the references to both would be lost (I assume they would point back to null
).
Is this concept I have correct?