我有三个名为FirstClass,SecondClass and ThirdClass
. 以下是三个类的来源:
第一类.java
public class FirstClass {
public void firstMethod(){
SecondClass secondClass = new SecondClass();
secondClass.secondMethod();
}
public static void main(String[] args) {
FirstClass firstClass = new FirstClass();
firstClass.firstMethod();
}
}
第二类.java
public class SecondClass {
public void secondMethod(){
ThirdClass thirdClass = new ThirdClass();
thirdClass.thirdMethod();
}
}
第三类.java
public class ThirdClass {
public void thirdMethod(){
System.out.println("Here i need to print where the call comes from,(call hierarchy) Is it possible?");
}
}
在最终方法(这里是ThirdClass.thirdMethod()
)上,我需要打印方法调用的来源(我的意思是调用层次结构)。所以我需要为此写thirdMethod()
什么