  The measurements of the inclusive J/$\psi$ yield at midrapidity ($\left | y
\right | < 0.9$) and forward rapidity (2.5 $< y <$ 4) in Pb$-$Pb collisions at
$\sqrt{s_{\mathrm{NN}}}=5.02$ TeV with the ALICE detector at the LHC are
reported. The inclusive J/$\psi$ production yields and nuclear modification
factors, $R_{\rm AA}$, are measured as a function of the collision centrality,
J/$\psi$ transverse momentum ($p_{\rm T}$), and rapidity. The J/$\psi$ average
transverse momentum and squared transverse momentum ($\langle
p_{\mathrm{T}}\rangle$ and $\langle p_{\mathrm{T}}^{\mathrm{2}}\rangle$) are
evaluated as a function of the centrality at midrapidity. Compared to the
previous ALICE publications, here the entire Pb$-$Pb collisions dataset
collected during the LHC Run 2 is used, which improves the precision of the
measurements and extends the $p_{\rm T}$ coverage. The $p_{\rm T}$-integrated
$R_{\rm AA}$ shows a hint of an increasing trend towards unity from semicentral
to central collisions at midrapidity, while it is flat at forward rapidity. The
$p_{\rm T}$-differential $R_{\rm AA}$ shows a strong suppression at high
$p_{\rm T}$ with less suppression at low $p_{\rm T}$ where it reaches a larger
value at midrapidity compared to forward rapidity. The ratio of the $p_{\rm
T}$-integrated yields of J/$\psi$ to those of D$^{0}$ mesons is reported for
the first time for the central and semicentral event classes at midrapidity.
Model calculations implementing charmonium production via the coalescence of
charm quarks and antiquarks during the fireball evolution (transport models) or
in a statistical approach with thermal weights are in good agreement with the
data at low $p_{\rm T}$. At higher $p_{\rm T}$, the data are well described by
transport models and a model based on energy loss in the strongly-interacting
medium produced in nuclear collisions at the LHC.

Nuclear Experiment;High Energy Physics - Experiment