In Java, the finalize method is called by the garbage collector when it determines that an object is no longer reachable.