In Shao's mathematical statistics, a problem asks to show for r.v. $X$ with cdf $F$, the expectation (provided it exists) can be evaluated as: $$ EX=\int_0^\infty[1-F(x)]dx-\int_{-\infty}^0F(x)dx $$ I can't convince myself why the integral bounds change the way they do, once Fubini's theorem is used to swap the order of integration.
Here's the start of his solution: $$ \begin{align*} \int_0^\infty[1-F(x)]dx&=\int_0^\infty\int_x^\infty dF(y)dx\\ &=\int_0^\infty\int_0^ydxdF(y) \end{align*} $$ This might be a basic calc misunderstanding, but hopefully someone could clarify.