I encountered this method when I'm reading a java book. I've looked for its meaning in java doc but it's difficult to understand. Can you tell me its meaning in easy to understand way?
Asked
Active
Viewed 105 times
-1
-
2What don't you understand about the javadoc entry? – Sotirios Delimanolis Apr 15 '14 at 16:39
-
can you please state what is the difficulty? – tod Apr 15 '14 at 16:42
2 Answers
1
Simple Phrase
Print stack trace tells you two things:
- Where you are (in the code)
- How you got there
Example
If main()
calls foo()
, foo()
calls bar()
, and bar()
calls printStackTrace()
, you will get a structure that looks like main() => foo() => bar().

Rainbolt
- 3,542
- 1
- 20
- 44
0
It prints the stack trace (most probably of an exception) to the console.
The stack trace specifies where in the code (hierarchically) you have been when the exception has been thrown, e.g.:
in method Worker.Run in Worker.java
called from method Main in Program.java
...
The format is different, but you should get the notion.
This helps you to learn which execution stack caused the exception (hence the name stack trace).

D.R.
- 20,268
- 21
- 102
- 205