Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

suryansh
5,993 PointsExplanation about printStackTrace() method
I do not understand the function of the printStackTrace() method, why and when we should use it. Any explanation is very much appreciated.
Thank you!
1 Answer

Craig Dennis
Treehouse TeacherSo printing the stack trace allows you to explain where the program is currently running. Methods end up on what is known as a call stack. This will probably grow into confusion quickly, as this is way later in the track, but here is a video I made about frames, feel free to stop watching that as soon as it gets confusing ;).
So printStackTrace
is used to help you and other devs locate the problem when it happens.
Does that help?
suryansh
5,993 Pointssuryansh
5,993 PointsIt helps quite a lot actually, thank you! I'm sure by the time I'm done with the Java Application course, I'll have a good grasp :)