# Are elements commutative when subgroups are?

Suppose G is a group and for every $H_1,H_2\le G$, $H_1H_2=H_2H_1$. Is $G$ abelian?

-

Let $H_1$ and $H_2$ be subgroups of $G$. Then $H_1H_2 = H_2H_1$ if and only if $H_1H_2$ is a subgroup.
Thus if for example every subgroup of $G$ is normal, then $H_1H_2$ is always a subgroup. The quaternion group of order $8$ is a nonabelian group where every subgroup is normal.
@SwapnilTri: Your mistake was thinking that $HK = KH$ implies that $hk = kh$ for all $h \in H$ and $k \in K$. This is not true. What $HK = KH$ implies is that for all $h \in H$ and $k \in K$, we have $hk = k'h'$ for some $k' \in K$, $h' \in H$ (not necessarily $h = h'$, $k = k'$) –  Mikko Korhonen Jul 13 at 13:23