fork download
  1. class Substring {
  2.  
  3. private static void substrings(String str) {
  4. if (str.length() >= 1) {
  5. System.out.println(str);
  6. substrings(str.substring(1));
  7. }
  8. }
  9.  
  10. private static void todasSubstrings(String str) {
  11. int tam = str.length();
  12. if (tam >= 1) {
  13. substrings(str);
  14. str = str.substring(0, str.length() - 1);
  15. todasSubstrings(str);
  16. }
  17. }
  18.  
  19. public static void main(String[] args) {
  20. todasSubstrings("UTFPR");
  21. }
  22. }
Success #stdin #stdout 0.06s 27832KB
stdin
Standard input is empty
stdout
UTFPR
TFPR
FPR
PR
R
UTFP
TFP
FP
P
UTF
TF
F
UT
T
U