每天都进步的课堂随笔Day07

Recursion

  • Method A call method B, it is easy to grasp!

  • Recursion: Method A call method A, that is method A call itself.

  • Using recursion could solve some complex matters, it usually swap a big and complex problem to a small scale problem, recursion strategy need less coding to state the progress of solving problem, it could reduce repetitive calculation. The abilities of recursion is to use finite statements to define infinite collection of objects.

  • Recursion structure including two parts as following:

  • Head of recursion: time not to method-self, without head it would lost in endless loop.

  • Body of recursion: time ought to call method-self.

  • package com.example.demo08.mehod;
    
    public class Demo05 {
        public static void main(String[] args) {
            Demo05 test = new Demo05();
            test.test();
        }
    
        public void test(){
            test();
        }
    }
    
  • package com.example.demo08.mehod;
    
    public class Demo06 {
      //阶乘
        //2! 2*1
        //3! 3*2*1
        //5! 5*4*3*2*1
        public static void main(String[] args) {
    
            System.out.println(f(5));
        }
        public static int f(int n){
            if( n== 1){
                return 1;
            }else{
                return n*f(n-1);
            }
        }
    }
    

Arrays

  • Summary of Arrays
  • Statement of creating Arrays
  • Using of Arrays
  • Multidimensional Array
  • Class of Arrays
  • Sparse Arrays
posted @ 2022-09-15 17:39  坚持就是胜利奥里给  阅读(19)  评论(0)    收藏  举报