Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. public class StringRecursion
  2. {
  3. public static void printLetters(String str)
  4. {
  5. if(str==null)
  6. {
  7. System.out.println(str);
  8. }
  9. else
  10. {
  11. System.out.print(str.charAt(0)+", ");
  12. str=str.substring(1, str.length());
  13. printLetters(str);
  14. }
  15. }
  16.  
  17. public static void main(String[] args)
  18. {
  19. printLetters("Testing 123");
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement