Let $R$ be a PID, and $r\in R- \{0\}$. Prove that $\langle r\rangle$ maximal $\iff r$ irreducible.
"$\Leftarrow$"Easy.
"$\Rightarrow$"If $J=\langle r \rangle$ then we will prove that $r$ is irreducible. If $r=ab$, we want to prove that $a\in U(R)$ or $b \in U(R)$.
If we take the ideal which is generated by $\langle a\rangle$ then (because $J$ is maximal)$$\langle a\rangle \subseteq\langle r \rangle \iff r\mid a \iff a=kr, k\in R \Longrightarrow r=krb\iff r(1-kb)=0_R \iff kb=1_R$$ so $b\in U(R)$. Same way if we work with $\langle b \rangle$.
Is this proof right?
The argument is not completely correct.
If I understand correctly you start with "(because $J$ is maximal) $\langle a\rangle \subseteq\langle r \rangle $", but it is not true that if you chose some maximal ideal then every other ideal is contained in it.
Instead argue like this if $r= ab$ then $r \in \langle a \rangle$ and thus $\langle r \rangle \subset \langle a \rangle$. Since $\langle r \rangle$ is maximal it follows that $\langle r \rangle = \langle a \rangle$ or that $ \langle a \rangle =R$.
Then continue from there.