In an inelastic collision of two bodies, the two bodies collide and stick together. We generally ignore any outside forces on the colliding objects, so the two-object system is an isolated system. This is reasonable in practice if we examine the objects immediately before and after the collision. This is because forces like friction, gravity, etc., do not have time to exert any appreciable impulse on the system.
The standard method for handling inelastic collisions in one dimension is to apply the law of conservation of momentum. After all, if no external forces act on a system, its total momentum will be conserved.
Suppose two bodies of masses m1 and m2, moving with velocities v1 and v2 in the same direction collide inelastically. After collision they will move with a common velocity, suppose v. Applying the conservation of momentum,
Pinitial=Pfinal
⇒m1v1+m2v2=(m1+m2)v
⇒v=m1v1+m2v2m1+m2