[5216] in java-interest

home help back first fref pref prev next nref lref last post

Is 'new' really necessary?

daemon@ATHENA.MIT.EDU (kkobashi@ix6.ix.netcom.com)
Fri Feb 2 05:40:45 1996

Date: Fri, 2 Feb 1996 00:53:06 -0800
To: java-interest@java.sun.com
From: kkobashi@ix6.ix.netcom.com

Can someone tell me why the 'new' keyword was used in Java?
It appears to me that its only use is as a token to
denote that a class instanciation is coming up next.
It seems redundant in that regard.

Given:
   (a) Date d = new Date(CurrentTime);      // Java compiler likes
   (b) Date d(CurrentTime);                 // Java compiler doesn't like
   (c) Date d;                              // Java compiler likes

Statement (a) uses the 'new' keyword. The disadvantage
is that it messes up C++ programmers to thinking that a dynamic
variable is being created (yes, Java doesn't have pointers but some
habits are hard to break). In addition, one has to type the class
symbol again, and the equal character.

Statement (b) is far more terse and natural for C++ programmers.

Statement (c) needs to be put in contrast to the following:
   Date d = new Date();

I hope you see my point. An instanciation is an instanciation.
Why must I think about a "new" object?

Kerry Kobashi
Kobashi Computing


-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post