Originally posted by Garrett Smith: getRunnable() is static.
Garrett, You have declared an anonymous class inside of a static method. Although the text used to declare the anonymous class appears "inside" of a static method, the anonymous class itself is not static. An instance of the anonymous class exists and instance methods within the anonymous class are able to refer to that instance using the "this" reference. For the purposes of the SCJP exam, a statement such as
The keyword "this" can not be used inside the body of a static method.
refers to the immediately enclosing method. The question does not refer to an instance method within an instance of an inner class declared within the body of a static method. I hope that helps.
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
But the this and the super have nothing to do with getRunnable(). Their context is the instance of the anonymous subclass of Runnable. And you are using them in a nonstatic method, that is run(). Sort of... -Barry Sorry Dan didn't see your post down there... [ February 10, 2003: Message edited by: Barry Gaunt ]