Skip to content

Instantly share code, notes, and snippets.

@smamran
Last active September 20, 2015 09:20
Show Gist options
  • Save smamran/fc94732c50e125aea8f5 to your computer and use it in GitHub Desktop.
Save smamran/fc94732c50e125aea8f5 to your computer and use it in GitHub Desktop.
Stack Tracing for a function.
package com.netcse.java;
public class Main {
public static void main(String[] args) {
StackTraceElement[] stackTraceElement = Thread.currentThread().getStackTrace();
for (StackTraceElement s : stackTraceElement) {
System.out.println(s.toString());
}
System.out.println("-----------------------------------------");
calc();
}
public static void calc() {
System.out.println("This is calc");
StackTraceElement[] stackTraceElement = Thread.currentThread().getStackTrace();
for (StackTraceElement s : stackTraceElement) {
System.out.println(s.toString());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment