class MethodDemo{
private String name;
private void show(){
System.out.println("我被调用了,我的名字是:"+name);
}
class inner{
public void change(){
name="king";
show();
}
}
public void addMethod(){
new inner().change();
}
}
public class Test {
public static void main(String[] args) {
new MethodDemo().addMethod();
}
}
结果:我被调用了,我的名字是:king
作者: 黄小贝 时间: 2013-4-2 22:26
public class Test {
private int myField = 0;
private void myMethod(){
System.out.println("the method was invoked and myFiled = " + myField);