Try this piece of code. Why does getValueB() return 1 instead of 2? After all, the increment() function is getting called twice.
public class ReturningF
The purpose of the finally method is to ensure that ressources are closed in any case. Consider the example:
public List getPersons() {
Connection conn = openConnection();
try {
return selectPersons(conn);
} finally {
conn.close()
}
}
The conn.close() statement is executed AFTER selectPersons(conn) is executed. Otherwise selectPersons(conn) would raise an connection closed error.