比如这样的一个类:package test;
public class Hello { public static void main(String[] args) {
Hello h = new Hello(); h.fun1();
} public void fun1() {
System.out.println("in fun1.");
System.out.println(fun2());
} public static String fun2() {
System.out.println("in fun2.");
return "hello";
}
}
在fun1中需用到fun2,但是这样只能使用static静态化fun2,有其他方法吗?
还是就是标题的问题,如何避免使用静态方法?