java - Lifecycle of non-referenced objects as parameters -


for instance...

incomingtemplate = factory.newtemplates(new streamsource(utils.getresource(... 

the streamsource object un-referenced ( there better term this? ) hence 1 cannot call it's close method ensure it's resources cleared up.

are these objects different normal local variables? affected whether object reference ( incomingtemplate) static?

this code

streamsource ss = new streamsource(utils.getresource()); incomingtemplate = factory.newtemplates(ss); 

is equal

incomingtemplate = factory.newtemplates(new streamsource(utils.getresource())); 

the difference not have direct access streamsource anymore, if use second variation.


however if incomingtemplate has getstreamsource method, doesnt matter, if use :

streamsource ss = new streamsource(utils.getresource()); incomingtemplate = factory.newtemplates(ss); 

or :

incomingtemplate = factory.newtemplates(new streamsource(utils.getresource())); streamsource ss = incomingtemplate.getstreamsource(); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -