Java基础知识强化之IO流笔记11:递归之递归概述和注意事项

1. 递归:

方法定义中调用方法本身的现象。

e.g:

1 public  void show(int  n ) {
2             if(n <= 0)  {
3                      System.exit(0);
4              }
5              System.out.println(n);
6              show(--n);
7 }

注意事项:

    (1)递归一定要有出口,否则就是死循环

    (2)递归的次数不能太多,否则就内存溢出

  (3)构造方法不能递归使用

原文地址:https://www.cnblogs.com/hebao0514/p/4850078.html