public class Solution {
public static void main(String[] args) throws Exception {
int deep = getStackTraceDepth();
}
public static int getStackTraceDepth() {
// write your code here
StackTraceElement[] element = Thread.currentThread().getStackTrace();
System.out.println(Arrays.toString(element));
return element.length;
}
}
Any idea?package com.codegym.task.task09.task0905;
/*
In the blue depths of the stack trace…
*/
import java.util.Arrays;
public class Solution {
public static void main(String[] args) throws Exception {
int deep = getStackTraceDepth();
}
public static int getStackTraceDepth() {
// write your code here
StackTraceElement[] element = Thread.currentThread().getStackTrace();
System.out.println(element);
return element.length;
}
}