Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. package SixPrograms;
  2. import java.util.*;
  3. public class recursiveString {
  4. static Scanner scan=new Scanner(System.in);
  5. public static void main(String[]args) {
  6. String word=scan.next();
  7. int a=scan.nextInt();
  8. System.out.println(method(word,a));
  9. }
  10. public static String method(String word,int a) {
  11. if(a==0)
  12. return "";
  13. return word.substring(0,a)+method(word,a-1);
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement