Using the conjugacy class equation: $\displaystyle |G| = |Z(G)| + \sum [G: C(x)] $ i want to show that there exists a non-abelian group of order $\displaystyle p^3 $. I know that $\displaystyle |G| = p^3 $ and since i want a non-abelian group, $\displaystyle |Z(G)| = p $ or $\displaystyle p^2 $. If |Z(G)| = p^2, then |G/Z(G)| = p but then that would mean G/Z(G) is cyclic with order p which cannot be since G/Z(G) is never a nontrivial cyclic group. therefore |Z(G)| = p. likewise each [G: C(x)] must be either p or p^2 since if it was $\displaystyle p^3 $ then |C(x)| = 1 which contradicts the definition of the class equation, and if the index = 1, then |C(x)| = $\displaystyle p^3 $ which means Z(G) = G. Then i say that each [G: C(x)] = p and if there are $\displaystyle p^2 - 1 $ of them, then $\displaystyle (p^2 - 1)p + p = p^3 - p + p = p^3 $ which is the correct order of the group. But also, if each [G: C(x)] = p^2, and if there are p-1 of them, then $\displaystyle (p-1)p^2 p = p^3 - p + p = p^3 $ which is also the correct order.

i am having trouble with the last part, since it seems like since we have a sum, a bunch of the [G: C(x)] can be p while a bunch of other could be $\displaystyle p^2 $ and when you add them all together and add them to $\displaystyle p $ we might somehow get $\displaystyle p^3 $. in other words, there doesn't seem to be a reason why each conjugacy class must have the same number of elements. although i assumed so to simplify things and to check that it worked, i don't know how to deal with the case if not all of the conjugacy classes are the same order. Could someone help fix up the end of my proof? thanks.