Q:

will this finally block execute?

Possible Duplicate:
In Java, does return trump finally? 

I came across a java code snippet in a dao implementation .It returns a List as shown below.
After the  'return' statement is executed,the finally block tries to close the session.Will this work? or will the session remain open?
thanks
mark
import org.hibernate.SessionFactory;
import org.hibernate.Criteria;
...
public List<Item> findItems(String name) {
    SessionFactory factory = HibernateUtil.getSessionFactory();
    Session session = factory.openSession();
    try{
        Criteria cri = session.createCriteria(Item.class);
        return (List<Item>) cri.add(Restrictions.eq("name", name)).list();
    } finally {
        session.close();
    }
}

A:

The only time a finally block will not be executed is if you terminate your program such as System.exit(0) or force quit etc. So the answer is: Yes, your session will be closed.

A:

Read up on The finally Block, and yes, the finally block will be executed after the return.

