java 如何测栈的深度

 

</pre><pre name="code" class="java">public class Test {
	int i=1;
	public static void main(String[] args) {
		Test test =new Test();
		try{
			test.study();
			//Throwable  是 Exception Error的共同父类 
		}catch(Throwable e){
			System.out.print(test.i );
		}	
	}
	//死递归:没有结束条件的递归
	public void study(){
		//使用计数器计算栈的深度
		i++;
		study();
	}
}


posted @ 2018-01-12 16:44  九间房  阅读(778)  评论(0编辑  收藏  举报