M
Mike Schilling
Arne said:But the static method can not be called from a static context,
so whatever it does could be achieved by making it non static.
And regarding counting instances, then look at what Mike Schilling
considers sensible.
Perhaps I wasn't clear, becasue what I'm thinking counts instances
quite well, e.g.
class Outer
{
class Inner
{
static int count;
Inner()
{
count++;
}
}
}
"count" willl give the number of Inner.Outer instances ever created,
regardless of the value of the enclosing Inner instance. Though in
fact what I've usually wanted a static method for is when Inner needs
a cache, e.g.
class Outer
{
class Inner
{
static Map<String, Schema>schemas = new HashMap<String,
Schema>();
private Schema schema;
Inner(String namespace)
{
synchronized(schemas)
{
schema = schemas.get(namespace);
if (schema == null)
{
schema = loadSchema(namespace);
schemas.put(namespace, schema);
}
}
}
}
}
Again, I want to use the same cache regardless of the value of the
enclosing instance.