Hi all,
Here is the question from K&B's CD:
class Bing {
Bing(
String s) {};
Bing() {};
}
class Bang extends Bing {
Bang() {};
Bang(String bangS) {super(bangS);};
// inserted here
}
The question is which line can be inserted at // without produces error. One answer is
Bing b = new Bing() {"Foo";};
However, I am not understand why the above statement is OK. So I inserted this line and compile, following error is raised:
Bang.java:9: illegal start of type
Bing b = new Bing() {"Foo";};
^
Bang.java:9: <identifier> expected
Bing b = new Bing() {"Foo";};
^
2 errors
Why such error produced in compiling?
Thanks,
David