Re: Singletons?
- From: Ian Shef <invalid@xxxxxxxxxxxxx>
- Date: Tue, 13 Jun 2006 19:32:10 GMT
Mark Space <markspace@xxxxxxxxxxxxx> wrote in news:FEDjg.147331$F_3.107067
@newssvr29.news.prodigy.net:
Hi all!
I'm trying out some new Java code. I was surprised to find that Java
doesn't allow the static keyword for classes. How was I to implement
singleton objects then? Well, a quick web search and I've got the
answer, but now I have a few other questions on the JVM and compiler.
Let's say I have a class entirely of static methods:
public class anAPI {
static void methodA {}
static void methodB {}
}
I don't know the answer to your questions, but you can sidestep the questions
by defining a no-argument constructor and giving it the "private" keyword.
This way, there is no way that this class can be instantiated unless one of
its own static methods does the deed. [Well, maybe there is a cheat via
reflection.]
Your questions are still valid, and I am interested in the answers myself.
--
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *
.
- Follow-Ups:
- Re: Singletons?
- From: Mark Space
- Re: Singletons?
- From: Oliver Wong
- Re: Singletons?
- References:
- Singletons?
- From: Mark Space
- Singletons?
- Prev by Date: Re: Check if your IDE properly syntax-highlights this code.
- Next by Date: Re: Singletons?
- Previous by thread: Re: Singletons?
- Next by thread: Re: Singletons?
- Index(es):
Relevant Pages
|