This is not an anonymous object (or rather an anonymous class). It is simply not an assigned object.
store , GC'd. store , , store. close, , , finalize close ad other do not, - GC.
, , close.
try-with-resources ( Java > try-with-resources) :
Properties p = new Properties();
try (FileOutputStream stm = new FileOutputStream("nameOfFile"))
{
p.store(stm, "Created by me.");
} catch (IOException e) {
// TODO: handle this
}
, ( ) Autocloseable, close , close close. , close , close e.getSuppressed().
Autocloseable.close() , , - . Closeable, . :
, Closeable
Java 6 , , , , close .