我的静态函数中,想要调用本类中的非静态方法,这可行吗?是不是非得让那个被调用的haha函数用static修饰才行呢,请教大家。- class Person
 
 - {
 
 -         String name;
 
 -         static String country = "CN";
 
 -         public static void show()
 
 -         {
 
 -                 System.out.println("::::");
 
 -                 this.haha();//不论有没有this,都是不能调用的。这地方肯定不能用this
 
 -         }
 
 -         public void haha()
 
 -         {}
 
 - }
 
  
- class  StaticDemo
 
 - {
 
 -         public static void main(String[] args) 
 
 -         {
 
 -                 Person.show();
 
 -         }
 
 - }
 
  复制代码 |