In this paper, first-principle calculations were used to determine the mechanical and electronic properties as well as the elastic anisotropy of ZrN2 and HfN2. Young's modulus, shear modulus, Poisson's ratio, and anisotropy under different pressures were studied. It has been shown that ZrN2 and HfN2 can be stable up to at least 100 GPa. The value of B=G increased with pressure, indicating that both ZrN2 and HfN2 are ductile. The values of AU, A1, and A2 are not 0, signifying that both ZrN2 and HfN2 have anisotropy. [ABSTRACT FROM AUTHOR]