Content deleted Content added
→Language constructs: add Java "try-with-resources" reference link |
m WP:CHECKWIKI error #61 fixed + general fixes using AWB (8884) |
||
Line 1:
{{redirect|Dispose||Disposal (disambiguation)}}
{{Refimprove|date=February 2013}}
In [[computer programming]], the '''dispose pattern''' is a [[design pattern (computer science)|design pattern]] which is used to handle resource cleanup in [[runtime environment]]s that use [[automatic garbage collection]]. The fundamental problem that the dispose pattern aims to solve is that, because objects in a garbage-collected environment have [[finalizer]]s rather than [[destructor (computer science)|destructors]], there is no guarantee that an object will be destroyed at any deterministic point in time. The dispose pattern works around this by giving an object a [[method (computer science)|method]] (usually called <code>Dispose</code> or similar) which frees any resources the object is holding onto.
Line 59:
</source>
The [[Java (programming language)|Java]] language introduced a new syntax called <code>try</code>-with-resources in Java version 7
<source lang="java">
try ( OutputStream x = new OutputStream(...) ){
|