Created
December 3, 2015 18:34
-
-
Save ProZhar/8c3b92f8ad628e239296 to your computer and use it in GitHub Desktop.
com.javarush.test.level09.lesson02.task02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson02.task02; | |
/* И снова StackTrace | |
Написать пять методов, которые вызывают друг друга. Каждый метод должен возвращать имя метода, вызвавшего его, полученное с помощью StackTrace. | |
*/ | |
public class Solution | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
method1(); | |
} | |
public static String method1() | |
{ | |
method2(); | |
//напишите тут ваш код | |
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); | |
return stackTraceElements[2].getMethodName(); | |
} | |
public static String method2() | |
{ | |
method3(); | |
//напишите тут ваш код | |
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); | |
return stackTraceElements[2].getMethodName(); | |
} | |
public static String method3() | |
{ | |
method4(); | |
//напишите тут ваш код | |
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); | |
return stackTraceElements[2].getMethodName(); | |
} | |
public static String method4() | |
{ | |
method5(); | |
//напишите тут ваш код | |
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); | |
return stackTraceElements[2].getMethodName(); | |
} | |
public static String method5() | |
{ | |
//напишите тут ваш код | |
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); | |
return stackTraceElements[2].getMethodName(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment