Since LaTeX is meant primarily intended for printed text I would strongly recommend you to not use e.g. grey background, but just use a typewriter font, e.g.
The class \texttt{List.class} is \ldots
You can and should wrap this in a new command to be free to change the visual appearance later, e.g.
\newcommand{\code}[1]{\texttt{#1}}
so you can use a form which is free of formating distractions and conveys intention more clearly
The class \code{List.class} is \ldots
If, however, you are intent upon marking the text with a gray background, you can extend the above format with a color definition and colorbox from the colors or xcolors package, e.g.
\definecolor{codegray}{gray}{0.9}
\newcommand{\code}[1]{\colorbox{codegray}{\texttt{#1}}}
For more on the colors, see this tutorial for some other usage examples.
tcolorboxpackage: https://www.ctan.org/pkg/tcolorbox and add a customtcboxto your preamble with the style of choice:\newtcbox{\inlinecode}{on line, boxrule=0pt, boxsep=0pt, top=2pt, left=2pt, bottom=2pt, right=2pt, colback=gray!15, colframe=white, fontupper={\ttfamily \footnotesize}}– Jonathan E. Landrum Jul 24 '20 at 15:20