The implementation of getCrimes
includes a try/finally
block:
public List<Crime> getCrimes() {
List<Crime> crimes = new ArrayList<Crime>();
CrimeCursorWrapper cursor = queryCrimes(null, null);
try {
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
crimes.add(cursor.getCrime());
cursor.moveToNext();
}
} finally {
cursor.close();
}
return crimes;
}
What possibly throws an exception here? Why does the author choose to use a try/finally
block here, without a catch
or a throws
attribute on the method signature? This is also done in the getCrime
method.