I have this code that gives us all the substrings of a string of my choice :
static void subString(char str[], int n) {
for (int len = 1; len <= n; len++) {
for (int i = 0; i <= n - len; i++) {
int j = i + len - 1;
for (int k = i; k <= j; k++) {
System.out.print(str[k]);
}
System.out.println();
}
How can I rewrite it in a way that show us the most frequent substring?