• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing an object to a method.

 
Ransika deSilva
Ranch Hand
Posts: 524
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's an anonymous inner class.
 
Erik Pragt
Ranch Hand
Posts: 125
  • 0
  • 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
  • 0
  • 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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic