【发布时间】:2020-12-12 03:38:56
【问题描述】:
这是我的主要课程:
public class App {
public static void main(String[] args){
Student s1=new Student();
};
};
这是创建的类:
class Student {
public static void f1(){
f2();
}
public static String f2(){
return "hello";
}
public Student(){
f1();
}
}
现在,因为我在主类中创建了一个对象 s1,所以调用了构造函数,它有 f1(),所以 f1() 被调用,现在 f1() 有 f2(),所以 f2() 被调用,所以我认为必须打印“你好”,但根本不打印输出(什么都不打印)。谁能解释一下可能是什么原因?
【问题讨论】:
-
这里没有任何东西可以打印任何东西。你的期望是没有根据的。
标签: java function class methods