Order of a center of a group is prime order

Question : Suppose that $G$ is a non-abelian group of order $p^{3}$ where $p$ is prime and $Z (G) \neq \{e\}$. Prove that $|Z (G)| =p$.

Any useful hint to this question is appreciated.

Since the center is non trivial his order can be $p,p^2$ or $p^3$. But $G$ is non abelian, so $|Z (G)|\neq p^3$.
Also if $|Z (G)|=p^2$, then $|G/Z|=p$, so $G/Z$ is cyclic, so $G$ is abelian (proof here).
Finally $|Z (G)|=p$.
• I never remember, how to construct a non abelian $|H| = p^2$ ? Commented Jul 14, 2016 at 11:25
• What is $H$ ? ${}$ Commented Jul 14, 2016 at 11:26
• Well all the groups of order $p^2$ are abelian, so you can't find such a group. Commented Jul 14, 2016 at 11:28
• yes that's what I just thought, with the same argument you used. How to construct $|G| = p^3$ non abelian then ? Commented Jul 14, 2016 at 11:29
• How does the fact that the center is non trivial lead us to deduce the possible order of the center as p, $p^{2}$ or $p^{3}$. Commented Jul 14, 2016 at 11:33