You're correct. The compiler will freak out. Runnable is an interface, and I don't think you can create "subinterfaces" anonymously like we can anonymous classes. I don't have the book laying around anymore so I can't tell you what the authors meant in the context. But what they might have been going for is something closer to:
Thanks. but if you have pay attention to that ";" after Runnable(), you will find out that it is not the case. The author might mean something like Runnable r = new MyRunnable();// MyRunnable is a class that implements Runnable.
Joined: May 29, 2003
True. If MyRunnable truly is a class that implements the Runnable interface the program would compile. Since we only instantiate classes, using "new" on an interface type will always result in a compilation error unless we are talking about an anonymous class.