Remember the golden rule: function A calls function B, which calls function C. And to exit A, you must first exit B, and to do that you must exit C. Got it? Good. And now we'll write a method that returns the stack trace depth, i.e. the number of methods in the stack trace. And one more thing: display this number on the screen.
In the blue depths of the stack trace…
- 3
Locked
Comments (18)
- Popular
- New
- Old
You must be signed in to leave a comment
Sander verhulst
3 September 2022, 19:59
I am not learning anything like this, i understand letting us do some googling but there is just way to less information on this topic.
0
Anonymous #10775689
2 August 2021, 08:54
CodeGym, please look at the exercise star rating and the comments. This Level needs more instruction.
+5
ImDevin
6 May 2021, 13:18
just getting it done. intellij doesn't give me any output. don't know why. for-each loop through StackTraceElement with .getMethodName does show 12 elements.
0
Vitalina
18 October 2020, 18:57
Intelij Idea shows me output 3 but CodeGym shows me output 12...
How have I understand it?
+4
Switch/Cypher
19 September 2020, 09:50
I'm completing these tasks with a lot of google and looking at the comments. I totally understand how the stacktrace works, but the programming terminology hasn't been explained AT ALL.
+4
Petros
27 July 2020, 00:53
Don't know how I'm completing these tasks without understanding much.
+4
Rafal Pawlowski
20 June 2020, 13:56
For everyone who is thinking why depth is equal some number use for each loop to print out stack trace to find out why is it so deep :)
0
Kent Hervey Software Engineer/Consult at Zeal IT ConsultantsExpert
31 January 2020, 20:40
I am completing these easily enough, but can't tell if I am learning anything
+3
Trevor
19 December 2019, 21:56
It's silly to have this fail when everything is right, but you called System.out in the 'wrong' method.
+1
Khairul
15 May 2019, 09:24
Why the Stack depth is 12 ?
+2
Ahmed
15 May 2019, 11:35
who said it's 12?
0
Khairul
15 May 2019, 12:11
element.length gives the value 12. So, doesn't it mean that the stack depth is 12? Please also clarify why the value is 12 and what is the actual stack depth?
0
Ahmed
15 May 2019, 12:55
I solved the problem and i didn't get 12. Put your code in the help session and i will help you
0
Khairul
15 May 2019, 21:53
Okay. I am posting it.
0
Khairul
15 May 2019, 21:59
Posted a question with the code. Please check and tell me. Thank you.
0
Ahmed
16 May 2019, 06:21
Sure.
0