Basically I am trying to get my code to print all substrings of a input. If the input is rum it would go as r u m ru um rum. I am not very good with nested loops and so far the out put I get is rr uu mm. I would appreciate if anyone can help me understand what I'm doing wrong here.
import java.util.Scanner;
public class NestedLoop {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String s = scan.nextLine();
for(int i = 0; i < s.length(); i++) {
char cur = s.charAt(i);
for (int j = 1; j < s.length(); j ++) {
char cu = s.charAt(j);
System.out.println(cur);
}
}
}
}