Example 2 Given that $x_{1}, x_{2}, \cdots, x_{10}$ are all positive integers, and $x_{1}+x_{2}+\cdots+x_{10}=99$. Find the maximum and minimum values of $x_{1}^{2}+x_{2}^{2}+\cdots+$ $x_{10}^{2}$.
Solution: Since there are only a finite number of ways to write 99 as the sum of 10 positive integers, there must exist a way that maximizes the sum of the squares of these 10 positive integers: and there must also exist a way that minimizes the sum of the squares of these 10 positive integers.

Assume $x_{1}, x_{2}, \cdots, x_{10}$ satisfy $x_{1}+x_{2}+\cdots+$ $x_{10}=99$, and make $x_{1}^{2}+x_{2}^{2}+\cdots+x_{10}^{2}$ reach its maximum value. Without loss of generality, assume $x_{1} \leqslant x_{2} \leqslant \cdots \leqslant x_{10}$.
If $x_{1}>1$, because
$$
x_{1}+x_{2}=\left(x_{1}-1\right)+\left(x_{2}+1\right) \text {, }
$$

and $\left(x_{1}-1\right)^{2}+\left(x_{2}+1\right)^{2}$
$=x_{1}^{2}+x_{2}^{2}+2\left(x_{2}-x_{1}\right)+2$
$>x_{1}^{2}+x_{2}^{2}$,
so, when using $x_{1}-1, x_{2}+1, x_{3}, \cdots, x_{10}$ to replace $x_{1}, x_{2}, \cdots, x_{10}$, their sum is still 99. But their sum of squares has increased. This contradicts the fact that $x_{1}, x_{2}, \cdots, x_{10}$ has already made $x_{1}^{2}+x_{2}^{2}+\cdots+x_{10}^{2}$ reach its maximum value, hence $x_{1}=1$.
Similarly, $x_{2}=x_{3}=\cdots=x_{9}=1$.
Thus, $x_{10}=90$.
Therefore, the maximum value of $x_{1}^{2}+x_{2}^{2}+\cdots+x_{10}^{2}$ is
$1^{2}+1^{2}+\cdots+1^{2}+90^{2}=8109$.
Next, find the minimum value of $x_{1}^{2}+x_{2}^{2}+\cdots+x_{10}^{2}$.
Assume $x_{1}, x_{2}, \cdots, x_{10}$ satisfy $x_{1}+x_{2}+\cdots+$ $x_{10}=99$, and make $x_{1}^{2}+x_{2}^{2}+\cdots+x_{10}^{2}$ reach its minimum value. Without loss of generality, assume $x_{1} \leqslant x_{2} \leqslant \cdots \leqslant x_{10}$.

If there exist $x_{i} 、 x_{j}(1 \leqslant i<j \leqslant 10)$, such that $x_{j}-x_{i} \geqslant 2$, because
$$
\begin{array}{l}
\left(x_{j}-1\right)^{2}+\left(x_{i}+1\right)^{2}-\left(x_{j}^{2}+x_{i}^{2}\right) \\
=2\left(x_{i}-x_{j}\right)+2 \\
\leqslant-2<0,
\end{array}
$$

so, when using $x_{i}+1$ and $x_{j}-1$ to replace $x_{i}$ and $x_{j}$, with other numbers unchanged, their sum is still 99, but their sum of squares has decreased. This contradicts the fact that $x_{1}^{2}+x_{2}^{2}+\cdots+x_{10}^{2}$ has already reached its minimum value.

Thus, when $x_{1}^{2}+x_{2}^{2}+\cdots+x_{10}^{2}$ reaches its minimum value, the absolute difference between any two of $x_{1}, x_{2}, \cdots, x_{10}$ does not exceed 1, hence, these 10 numbers can only be 1 9 and 9 10s. Therefore, the minimum value of $x_{1}^{2}+x_{2}^{2}+\cdots+x_{10}^{2}$ is
$$
9^{2}+10^{2}+\cdots+10^{2}=981 .
$$