The difference is only that one you do not see and the other you see, nothing else. The difference is the method println()
.
nothing happens
Wrong premise.
at this time a
Contradicts the premise.
The first creates the new instance and nothing else can be done with it. It cost to create, occupied memory and will remain there until the object is collected. The second code passes this object through a reference to the method println()
do what he knows how to do, then potentially have a lifespan guaranteed a little higher, but in practice we know that it does not matter in a simple example, the object will only be available for an instant in its creation and execution of the method.
In fact the problem itself has nothing to do with the fact that the object is immutable, that is circumstantial, any object that was created would occur the same.
Perhaps it lacks understanding of what a variable, She’s simpler than people realize.
Your first phase clarified for me rsrs, thank you.
– Roknauta