an problem for the range of integration of cdf Let X be a continuous, nonnegative random variable, and $F_X(x)$ is the cdf of X.
$\int_0^\infty P(X>x)dx=\int_0^\infty\int_x^\infty f_x(y)dydx=\int_0^\infty\int_0^ydxf_x(y)dy$
I don't know why the range is from $0$ to $y$ at the last term.
Thanks.
 A: Draw the line $y=x$.  In the middle integral, $y$ went from $y=x$ to $\infty$, and then $x$ went from $x=0$ to $\infty$.
So the full double integration was done over the part $K$ of the first quadrant that is above the line $y=x$.  Concentrate on $K$, a roughly triangular region.  Write $K$ in that reg. on.
Now we change the order of integration. For any fixed $y$, we  integrate first with respect to $x$. So $x$ goes from $x=0$ to the diagonal line. We have to stop there in order not to leave $K$. Thus  $x$ goes from $x=0$ to $x=y$. Then $y$ goes from $0$ to $\infty$.
Remark: The rest of the story is interesting. When we integrate with respect to $x$, where $x$ goes from $0$ to $y$, then $f_X(y)$ is being treated as a constant, and we get $yf_X(y)$. Now when we integrate with respect to $y$, we get $E(X)$. 
A: It's an application of Fubini's Theorem.   The bounds are decided because we are integrating over the domain of : $\{(x,y):0<x<y<\infty\}$ .   You can use sketches to help visualise it, but I find it's just as clear to look at it this way:
$$\begin{align}
&& \text{Where the intervals lay}
\\\int_0^\infty P(X>x)\operatorname dx & =\int_0^\infty\int_x^\infty f_X(y)\operatorname dy\operatorname dx
& (0<x<\infty) , (x<y<\infty)
\\[1ex] & = \iint_{(0<x<y<\infty)} f_X(y) \operatorname d(x,y)
& (0<x<y<\infty)
\\[1ex] & = \int_0^\infty\int_0^yf_X(y)\operatorname dx\operatorname dy
& (0<y<\infty),(0<x<y)
\\[1ex] & = \int_0^\infty f_X(y)\int_0^y\operatorname dx\operatorname dy
\\[1ex] & = \int_0^\infty y\,f_X(y)\operatorname dy
\\[1ex] & = \mathsf E(X)
\end{align}$$
