fork download
  1. class Substring {
  2. public static void todasSubstrings(String str) {
  3. for (int j = str.length(); j >= 0; j--) for (int i = 0; i < j; i++) System.out.println(str.substring(i, j));
  4. }
  5. public static void main(String[] args) {
  6. todasSubstrings("UTFPR");
  7. }
  8. }
  9.  
  10. //https://pt.stackoverflow.com/q/323222/101
Success #stdin #stdout 0.1s 27704KB
stdin
Standard input is empty
stdout
UTFPR
TFPR
FPR
PR
R
UTFP
TFP
FP
P
UTF
TF
F
UT
T
U