Java Exception Handling - Style

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

    Different people have different opinions.But It is recommended to use first option because if there is any trouble opening the cursor, an exception could be thrown and handled.That is one safe way of programming.

提交回复
热议问题