Gab*_*ira 3 java class inner-classes
我有这样的代码:
class Foo() {
time_to_play = 0
class Bar() {
void change_player() {
//I need something HERE
}
}
}
Run Code Online (Sandbox Code Playgroud)
我需要time_to_play从类中更改属性Foo,但是在方法内部进行此更改change_player(),即在类下Bar.
我不能在课堂Bar外宣布课程Foo,并做一个'扩展',并打电话给超级.......,因为在我的情况下它打破了OO.
另外,我不想做time_to_play一个静态变量,调用Foo.time_to_play
我怎么能这样做?
你想要的是:
void change_player() {
Foo.this.time_to_play = // something
}
Run Code Online (Sandbox Code Playgroud)