package com.company; public class Recursive { public static void main(String[] args) { long startTime=System.currentTimeMillis(); System.out.println("执行代码块/方法"); Sum(100000);//此时递归崩溃 long endTime=System.currentTimeMillis(); System.out.println("程序运行时间: "+(endTime - startTime)+"ms"); } public static void Sum(int x){ int n=x; if(n!=0){ Sum(n-1); System.out.println(n); } } }