I just want to get a little deep into this and present what brainpushups said mathematically, any object can be represented at a set of points, each of these point have a moment of inertia ## \delta I = \delta m\cdot r^2 ## (this is true because they are points each of mass delta m), and we know that ## I_{net} = \sum \limits_i \delta I ##, if we want to sum infinetely small quantities, our best option would be an integral so ## I_{net} = \int \delta I = \int r^2 dm ## .
For example if you want to determine to moment of intertia of a solid cylinder about its central axis, you start by defining ## \rho = \frac{m}{V} = \frac {m}{\pi R^2L} ## so that ## dm = \rho dV = \rho r\cdot dr\cdot d\theta\cdot dz ## and then set the boundaries, for example ## 0 \leftarrow r \rightarrow R, 0 \leftarrow \theta \rightarrow 2\pi ## and ## 0 \leftarrow z \rightarrow L ## and finally integrate ## I_{net} = \rho \int_0^L \int_0^{2\pi} \int_0^R r^3 \cdot dr\cdot d\theta\cdot dz = 2\pi L\rho \int_0^R r^3 \cdot dr = 2\pi L\cdot \frac {m}{\pi R^2L} \cdot \frac{R^4}{4} = \frac{1}{2} mR^2 ## Cheers :D