This is about problem 4 on page 482 of Sierra and Bates:
4. Given the following,
which two create an anonymous inner class from within class Bar? (Choose two.)
A. Boo f = new Boo(24) {};
B. Boo f = new Bar() {};
C. Boo f = new Boo() {
String s;};
D. Bar f = new Boo(String s) {};
E. Boo f = new Boo.Bar(String s) {};
The answer given in that book is B & C.
I don't understand why C is right.
{ String S; } simply does not make sense to me. Could you please explain the plain declaration
String s; to me? What is it trying to do in that curly braces?
Besides, will the following line create an anonymous inner class from within class Bar as shown above?
If not, why?
Thank you.
Gene
[ September 04, 2003: Message edited by: Gene Chao ]