Showing non-cyclic group with $p^2$ elements is Abelian
"Let $p$ be a prime number. Prove that any group $G$ of order $p^2$ is abelian. You may assume the fact that the centre of a $p$-group is non-trivial".
I understand from the question is that the group $G$ is a $p$-group, with $p^2$ number of elements in it (meaning it is finite). Also, the centre, i.e the set of elements where $g_1g_2 = g_2g_1$ for all $g_1, g_2 \in G$, is non-trivial, meaning $\neq e$.
So, the non-trivial bit shows that the center, $Z$, either generates the group, so it's cyclic and therefore abelian by definition. Or, it generates a subgroup of order p, and so $Z$ with some elements missing from group $G$ generate G, but as these groups commute (because they have a centre of $Z$), we can say the group is abelian.
Is this correct?