(==>) Suppose A x B = B x A. Since A and B are assumed to be nonempty, we can choose an element b of B.Let x be an arbtrary element of A. Then (x,b) is an element of A x B by definition. Then , by assumption, (x,b) is an element of B x A, wi=hich implies x is an element of B. Thus A is a subset of B.Similarly, choosing an element a of the nonempty set A, and an arbitrary element y of B, we have (y,a) an element of B x A, hence (y,a) is in A x B, implying that y is in A .Hence B is a subset of A.Thus A=B.

(<==) This is immediate: if A=B then A x B = A x A = B x A.

Note, if either A or B is \emptyset, then A x B is equal to \emptyset, and so A x B = \emptyset = B x A if one of A or B is the empty set.