Java Exception Handling - Style

后端 未结 8 1641
别跟我提以往
别跟我提以往 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:29

    The second style is fine as long as neither of the method arguments is a calculated expression that can throw its own exception and needs cleaning up after.

提交回复
热议问题