what is the difference in java objects created with "new" and the ones that do not use "new" -


what difference between creating object , without "new"?

example:

thing = new thing(); 

vs.

path filepath = path.get("c:\\......) 

in first example understand when instantiating object, "new" allocating memory object , memory location referenced something.

my text book says " create path object" using second example. difference how object stored or memory allocated? not sure why create object way.

in second case using static method internally creating object or passing reference existing object. common pattern particularly when apis wish hide internal implementation (as case here).


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -