Java Exception Handling - Style

后端 未结 8 1647
别跟我提以往
别跟我提以往 2021-01-17 15:42

Historically I have always written my Exception handling code like this:

    Cursor cursor = null;
    try {
        cursor = db.openCursor(null, null);
             


        
8条回答
  •  余生分开走
    2021-01-17 16:28

    There is really nothing wrong in doing :

    Cursor cursor = db.openCursor(null, null);  
      try {  
         // do stuff  
       } finally {  
          try {  
            cursor.close();  
         } catch( SomeOther so ){}  
     }  
    

提交回复
热议问题