This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes About anonymous inner class! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "About anonymous inner class!" Watch "About anonymous inner class!" New topic
Author

About anonymous inner class!

Tony Sam
Ranch Hand

Joined: Nov 19, 2001
Posts: 32
hi here,
Could a anonymous inner class have its own constructor ? if yes, could someone give me a sample about this, Some books say Yes,others say No. i am really really confused ...
Thanx in advance


Tony Sam<BR>One want to be a SCJP...
Hussain
Ranch Hand

Joined: Nov 22, 2001
Posts: 110
hi sam,
no const in annonemus class
but
a
intilize block
like this:
new Ann()
{
{
System.out.println("A");
}
};
------------------
Muhammad Hussain

Muhammad Hussain<br />Sun Certified Java Programer (SCJP2)<br />Sun Certified Web Component Devloper SCWCD
Nain Hwu
Ranch Hand

Joined: Sep 16, 2001
Posts: 139
Tony,
Just think why it is called "anonymous"?
It has no name and a constructor must have the same name as
its class. So, it is impossible to have a constructor for an anonymous class.
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
You cannot have constructor for anonymous inner class but if the parent class have constructors,then we can arrange to invoke one of the parent class constructors by passing the appropriate arguments...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About anonymous inner class!