Correct me if I'm wrong, but I do not believe top-level classes can have
the 'static' modifier applied, but if you want a shared entity, do
something like this:
public class DefaultFactory
extends AbstractFactory
{
protected DefaultFactory() { /* empty */ } // or private if you wish
public final static DefaultFactory SHARED_INSTANCE = new
DefaultFactory();
...
}
This is how I create shared entities (for example in JUMP, a framework for
numeric computations). The only potential problem you have here is
performance, if a piece of code synchronizes on the shared instance. But
then again, _most_ shared entities do not have state, so they should not
have to be synchronized. Malicious code could, however, cause a lifelock
problem by synchronizing on the shared entity and letting go...
GreetinX++, Ernst
Pavel wrote:
> > What is a static class?
> Making classes static has good sense if they are nested. Usually nested
> class object has hidden member referencing high level class object and
> hidden constructor parameters. But static nested class is just like a
> high level class. By the way, static public class nested in another
> public class is the single method I know to define more than one public
> class in one file. I have no idea whether static classes are
> syntaxically allowed on the top level. I think it does not matter -- all
> such classes are actually static in all senses I can image.
>
> Hope this helps.
>
> Pavel
--
+---------------------------------------------------------+
| "Come to me all you who are weary and burdened, and I |
| will give you rest." |
| |
| -- Jesus Christ (Mt. 11:28) |
+-----------------------+---------------------------------+
| Ernst de Haan | email [EMAIL PROTECTED] |
| Java programmer | web members.xoom.com/znerd/ |
+-----------------------+---------------------------------+