Good developers know that, (1) Exception Handling is costly and might use thousands of CPU cycles to process which, in turn could take several nanoseconds, and (2) Code Reuse is important, and definitely faster to reuse the same block of code than to have two similar blocks.

Gooder developers (such as Abraham's colleague) not only know these facts, but know how to apply them simultaneously to maximize Speed and Code Reuse…

for ( int i=0 ; i < 2; i++ ) //re-use the try catch block
 {
  try
   {
    switch( i )
    {
     case 0:
      if ( baos != null )
        {
         baos.close();
         baos = null;
        }
     break;
    
     case 1:
       if ( dos != null )
        {
         dos.close();
         dos = null;
        }
     break;
    
     default:
     break;

    }
   }
   catch ( IOException ioe2 ) {}
 }
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!