Let G be a nonabelian group of order $p^3$, where $p$ is a prime number. Prove that the center of $G$ is of order $p$.

I don't think the proof is correct. The following doesn't make sense to me.

We can also assume that $H$ and $Z(G)$ are disjoint. Otherwise, if there didn't exist a disjoint subgroup of order $p$, then the order of $G$ would be $p^2$.

As pointed out by user10444, typically you apply the statement

If G/Z(G) is cyclic, then $G$ is abelian.

to exclude the case $\lvert Z(G)\rvert = p^2$.

The statement is not hard to show: Let $gZ(G)$ be a generator of the cyclic group $G/Z(G)$. Then $G = \langle \{g\}\cup Z(G)\rangle$. Since each pair of generators of $G$ commutes, $G$ is abelian.


I have a question can somebody please clarify. Why is the possibility that $|Z(G)|=1$ not considered? Thanks!

UPDATE:

Here is my attempt at a solution.

Consider $Z(G)$ center of the group $G$. We know that $Z(G)\leq G$.

By Lagrange's Theorem $|Z(G)|$ must divide $|G|$.

Since $|G|=p^{3}$ the only possibilities are $1, p, p^{2}, p^{3}$.

$|Z(G)|\neq p^{3}$ because otherwise we will have $Z(G)=G$ but $G$ is non-abelian.

$|Z(G)|\neq p^{2}$ also because otherwise we will have the order of the factor group by the center as $|G/Z(G)|=|G|/|Z(G)|= p^{3}/p^{2} = p$.

We have:

$|G/Z(G)|=p \implies G/Z(G)$ is cyclic $\implies G$ is abelian. But $G$ is non-abelian.

Now $|Z(G)|\neq 1$ also because $G$ is a $p-group$ and $p-groups$ have non-trivial center.

(thanks to Tobias Kildetoft for pointing this out).

Thus the only possible order for $Z(G)$ is $p$.

$QED$