int i = 0; for (T x : set) { int j = 0; for (T y : set) { if (i >= j) { j++; continue; } System.out.println(x + "," + y); j++; } i++; }