I wanted return length but my trace look like this:
getStackTrace: line: 1559
getGlebokoscStosu: line: 15
main: line: 9
invoke0: line: -2
invoke: line: 62
invoke: line: 43
invoke: line: 498
callMainMethod: line: 74
...
12 methods in total.
What's happend here?
package pl.codegym.task.task09.task0905;
/*
Krok po kroku po śladach stosu...
*/
public class Solution {
public static void main(String[] args) throws Exception {
int glebokosc = getGlebokoscStosu();
System.out.println(glebokosc);
}
public static int getGlebokoscStosu() {
// tutaj wpisz swój kod
StackTraceElement elements[] = Thread.currentThread().getStackTrace();
for (StackTraceElement x : elements)
System.out.println(x.getMethodName()+": line: "+x.getLineNumber());
return elements.length;
}
}