---
title: "How to print stack trace in your java code?"
author: "standalone"
date: "2010-10-15T10:08:37Z"
tags: []
categories: ["编程语言"]
slug: "how-to-print-stack-trace-in-your-java-code"
draft: false
lastmod: "2010-10-29T15:23:56Z"
id: 785486
url: "https://standalone.iteye.com/blog/785486"
---

When debugging java code, sometimes it's important to know where you come from. So you can print current stack trace to help you.

 

1\. new Exception().printStackTrace();

2\. Thread.currentThread().getStackTrace(); This returns an array of StackTraceElement that represents current stack of your program.