Skip to content

Commit

Permalink
深入理解递归
Browse files Browse the repository at this point in the history
  • Loading branch information
Xikl committed Jun 25, 2019
1 parent 0f10b21 commit 72ceda5
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.ximo.datastructuresinaction.leetcode.recursive;

/**
* @author xikl
* @date 2019/6/26
*/
public class PrintReverse {

public static void printReverse(char[] strArray) {
printReverse(0, strArray);
}

/**
* 递归调用
*
* @param index 索引
* @param strArray 原始数组
*/
private static void printReverse(int index, char[] strArray) {
if (strArray == null || index > strArray.length) {
return;
}

// 我们假设先执行后面的
printReverse(index + 1, strArray);
// 然后再执行自己
System.out.println(strArray[index]);
}


}

0 comments on commit 72ceda5

Please sign in to comment.