i kept trying to change the number patterns but i just cant get the correct output =/
package com.codegym.task.task09.task0902;
/*
Stack trace revisited
*/
public class Solution {
public static void main(String[] args) throws Exception {
method1();
}
public static String method1() {
method2();
System.out.println(Thread.currentThread().getStackTrace()[3].getMethodName());
return Thread.currentThread().getStackTrace()[3].getMethodName();
}
public static String method2() {
method3();
System.out.println(Thread.currentThread().getStackTrace()[2].getMethodName());
return Thread.currentThread().getStackTrace()[2].getMethodName();
}
public static String method3() {
method4();
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
return Thread.currentThread().getStackTrace()[1].getMethodName();
}
public static String method4() {
method5();
System.out.println(Thread.currentThread().getStackTrace()[0].getMethodName());
return Thread.currentThread().getStackTrace()[0].getMethodName();
}
public static String method5() {
System.out.println(Thread.currentThread().getStackTrace()[3].getMethodName());
return Thread.currentThread().getStackTrace()[3].getMethodName();//write your code here
}
}