This library does finite permutations in Java. Cycle based Permutation.cycle(0, 1).apply(List.of("a", "b", "c")); // => ["b", "a", "c"] Composition Permutation.cycle(0, 1).compose(2, 3); // => (0 1) (2 3) Getting all permutations of 5 Elements Permutation.symmetricGroup(5).count(); // => 120 Permutation group: https://github.com/cicirello/JavaPermutationTools