This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What to do ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What to do ??" Watch "What to do ??" New topic
Author

What to do ??

Kumar Navin
Ranch Hand

Joined: May 27, 2004
Posts: 51
Dear Friends,
I have to fulfill two conditions while defining the class-
1) I don't want my class to be extended.
2) I don't want anyone to instantiate my class.
How do I do that as a class cannot be abstract and final at the same time.
Thanks.

-Navin.
arnel nicolas
Ranch Hand

Joined: Dec 16, 2003
Posts: 149
How about making the constructor of your class private.
Beny Na
Ranch Hand

Joined: May 26, 2004
Posts: 159
hehe..yes..making the contructor as private as Arnel said.

good reply Nicholas..
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
and mark the class itself as final.


42
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What to do ??
 
Similar Threads
don't create too much object?
ApplicationResources
Input Display
modify method in byte code using ASM.
Don't want to use ActionForm only Action class