Dima T wrote:
About exceptions I will fairly confess what not in course whence because of them (educate to whom not laziness)
I read brakes at Mejersa.
If briefly in pluses, the object created on a stack, exists only in the field of () visibility, and for object destruction answers , automatically caused by the compiler "on a closing parenthesis".
The exception "tears" a stack, "abandoning" many areas of visibility, the code, organizing calls therefore is necessary.
Besides, for support of operation with object in the catch-block, the object should be copied that too does not reduce code amount and execution time.
Because of copying restrictions in this case Mejers recommends to intercept always an exception on an object reference.
In Java where the garbage collector is engaged in clearing of storage of objects, problems are not present this.
The object "was lost" because on it there is no (acyclic) link? The garbage collector will be tidied up. In due course.
But, for the same reason, it is impossible to organize implicit clearing of resources in which there is no also all cleaning becomes in explicit finally-blocks.