TITLE: How to use stars and bars for solving number of integral solutions to an equality?
QUESTION [29 upvotes]: How to use the stars and bars method?
Say I want to find number of combinations I can get with $x_1+x_2+x_3+x_4=22$,
 where $x_i\in\mathbb{N}$.
Is this the correct time to apply the method?
This is being repurposed in an effort to cut down on duplicates, see here: 
Coping with abstract duplicate questions
and here: List of abstract duplicates

REPLY [19 votes]: The star method: consider 22 balls and 3 separations (because you have 4 boxes). I denote $*$ for the balls and $\Big |$ for the separation. Then it's the number of permutation of:
$$\left\{\underbrace{*\ *\ \cdots *\ }_{22\ balls}\Big|\hspace{0.5cm}\Big|\hspace{0.5cm} \Big|\hspace{0.5cm}\right\}$$
There is $25!$ permutations but the permutation of the balls together and the permutations of the separation together doesn't give a new combinaison, so you have to divide $25!$ by $3!22!$ and it gives
$$\frac{25!}{3!22!}=\binom{25}{3}$$ different solutions.