how to arange in lexicographical order
Lexicographical order
If you want to sort the subsequences lexicographically, then simply store them in an ArrayList and apply Collections.sort(list) on it! And simply print the list instead of printing it in base case!