Let random variables, $X$ and $Y$, be $X \sim \mbox{Geometry}(y)$ and $Y \sim \mbox{Uniform}(0, 1)$.
How can I find out $E[X]$?
The textbook said $$E[X]=\int_{0}^{1}\frac{1}{1-y}dy=\infty$$
Is the right process like the following? $$ E[X]=E\left[\frac{1}{1-Y}\right]=\int_{-\infty}^{\infty}\frac{1}{1-y}f_Y(f)dy=\int_{0}^{1}\frac{1}{1-y}dy=\infty $$
You could apply the formula for conditional expectation. You know that $X|Y\sim \text{Geom}(Y)$, so $E[X|Y] = \frac{1}{1-Y}$ on $\{0,1,2,3,\dotsc\}$. Thus $$E[X] = \int_{0}^1 E[X|Y]f_Y(y)\,dy = \int_{0}^1\frac{1}{1-y}\cdot 1\,dy=\int_{0}^1\frac{1}{1-y}\,dy$$
This is how you apply the formula.