如果另一个类中的那个方法是私有的话,就不能直接调用到,如果是其他类型的话看情况,如果是静态的(static)话,直接用类名可以调用到,如果是非静态的,就需要利用另一个类的实例(也就是用那个类生成的对象)来调用. 如 class A{public static void a(){}public void b(){} } public class B{public static void main(String[] args){A.a();//静态 new A().b();//非静态}}
Example4_9.java public class Example4_9 { public static void main(String args[]) { SIM simOne = new SIM(13889776509L); MobileTelephone mobile = new MobileTelephone(); mobile.setSIM(simOne); System.out.println("手机号码:"+mobile.lookNumber()); SIM si