This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing an object to a method.

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have this question. How this code snippet is allowed to compile.
amethod(new someclass() {} );
How can we have 'Curly Braces' after the constructor name?.
Thank you..
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's an anonymous inner class.
 
Erik Pragt
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, as an add-on, this even works for Interfaces.
*spooky* !!
 
Trent DiBacco
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and as another add on, this works with anonymous arrays as well.

[ January 11, 2004: Message edited by: Trent DiBacco ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic