[java]内部クラスの使い方
2006/06/05
2006/11/26
内部クラスの使い方を研究しています。
public class TestScope {
public static void main(String[] args) {
TestScope testScope = new TestScope();
testScope.getInneClass().print();
testScope.getInneClass().changeOk(true);
testScope.getInneClass().print();
}
protected boolean isOk = false;
InnerClass innerClass;
public TestScope(){
this.innerClass = new InnerClass();
}
public InnerClass getInneClass(){
return this.innerClass;
}
public class InnerClass {
public InnerClass(){
}
public void print(){
System.out.println(TestScope.this.isOk);
}
public void changeOk(boolean b){
TestScope.this.isOk = b;
}
}
}
public class TestScope {
public static void main(String[] args) {
TestScope testScope = new TestScope();
testScope.getInneClass().print();
testScope.getInneClass().changeOk(true);
testScope.getInneClass().print();
}
protected boolean isOk = false;
InnerClass innerClass;
public TestScope(){
this.innerClass = new InnerClass();
}
public InnerClass getInneClass(){
return this.innerClass;
}
public class InnerClass {
public InnerClass(){
}
public void print(){
System.out.println(TestScope.this.isOk);
}
public void changeOk(boolean b){
TestScope.this.isOk = b;
}
}
}
: