Guest User

Untitled

a guest
Nov 15th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public static void main(String[] args) {
  2.  
  3. String str = "ABCD";
  4.  
  5. char[] chars = str.toCharArray();
  6.  
  7. char[] charElements = new char[chars.length];
  8.  
  9. int charLen = chars.length-1;
  10.  
  11. int charInitialIndex = 0;
  12.  
  13. RecursiveArrayCopyAlgorithm testSearch = new RecursiveArrayCopyAlgorithm();
  14.  
  15. char[] charObjs = testSearch.callLinear(charLen, charInitialIndex, chars, charElements);
  16.  
  17. for (int i = 0; i < charObjs.length; i++) {
  18. System.out.println(charObjs[i]);
  19. }
  20.  
  21. }
  22.  
  23. private char[] callLinear(int charLen, int index,char[] ch, char[] charElements) {
  24. int index1 = charLen;
  25.  
  26. if(index1 < 0) {
  27. return charElements;
  28. }
  29.  
  30. if(index1 >= 0) {
  31. charElements[index] = ch[index1];
  32. }
  33.  
  34. return callLinear(charLen-1, index+1, ch, charElements);
  35. }
Add Comment
Please, Sign In to add comment