Seamus MacRae wrote:
Personally, I'd have designed the language to have constructors
automatically private. Static factory methods, with actual NAMES,
would be the way to return new instances. String's could share an
instance, and inefficient instance creation would rarely become
locked in by changing it breaking the API. Changing a ctor to a
static factory method breaks your API, whereas changing the
implementation of an existing static factory method may avoid
doing
so.
I concur. The "new" syntax taken from C++ is far less compelling
in
Java, where
1. There's no need to emphasize the fact that dynamic memory is
allocated, because that's how it *always* works.
2. The overloaded "new" used e.g. to allocate an object at a fixed
address is absent.
3. There's no "delete" to be the obverse of "new"
I'm every bit as happy to say
FileInputStream = FileInputStream.openm();
as
FileInputStream = new FileInputStream.(fname);
and readable.