Source: https://lipn.univ-paris13.fr/~gmanzonetto/~java/TD7_corr.pdf