"Hi, Amigo!"
"Hi, Diego!"
"Here’s a small task about displaying the stack trace."
15
Task
New Java Syntax, level 15, lesson 2
Returning a stack trace
There are five methods that call each other. You need to make each method return its stack trace.
15
Task
New Java Syntax, level 15, lesson 2
Stack trace revisited
There are five methods that call each other. You need to make each method return the name of the method that called it. Use the stack trace to obtain this information.
15
Task
New Java Syntax, level 15, lesson 2
Who called me?
There are five methods that call each other. You need the method to return the line number of the code from which it was called.
Use the element.getLineNumber() method.
15
Task
New Java Syntax, level 15, lesson 2
Logging stack traces
Implement the log method so that it displays the name of the file and method in which it is called, as well as the passed message.
Use a colon and space to separate the file name, method name, and message.
Example output:
Solution.java: main: In method
Getting the file name from a StackTraceElement
15
Task
New Java Syntax, level 15, lesson 2
Stack trace with 10 calls
Write the code to get a stack that is 10 calls deep. Don't change the main method.
15
Task
New Java Syntax, level 15, lesson 2
The method returns a result — the depth of its stack trace
Implement a method that returns the stack trace depth, i.e. the number of methods in the stack trace.
In the method, the same number needs to be displayed on the screen.