package jpastart.reserve.application;
import java.util.Optional;
import javax.persistence.EntityManager;
import jpastart.jpa.EMF;
import jpastart.reserve.model.User;
public class UserService {
public UserService() {
// // TODO Auto-generated constructor stub
}
public Optional<User> getUser(String email){
EntityManager em = EMF.createEntityManager();
try{
return Optional.ofNullable(em.find(User.class, email));
}finally{
em.close();
}
}
}
Even if there is a code that returns in the middle of the above code, will the final part be executed?
java c++ c#
Yes.
Even if the return statement is executed in the try block, the final block is executed.
© 2025 OneMinuteCode. All rights reserved.