[32] in java-interest
Re: syntax of "new"; packages
daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Mon May 1 19:09:55 1995
Date: Mon, 1 May 1995 09:52:11 -0700
From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
To: java-interest@java.Eng.Sun.COM
Hi Jeremy,
> I've been running my compiler over the sources in classsrc to see
> what breaks (which is surprisingly little (now)).
Cool. Does it generate code?
> In browser/hotjava.java, it uses the syntax "new String[12]". Is
> this the same as "new String()[12]"? It seems a little odd that
> a new of just an object must have argument parens, even if empty,
> but making an array of them doesn't explicitly require them.
Remeber that "new String[12]" does NOT allocate any strings. It only
allocates an array of 12 elements. This means that the ()'s are not
appropriate here.
> I've also started playing with proper package management. I'm
> unsure where in the grammar it is legal to use a fully qualified
> name. Is it, for example, valid to do this:
> package my.test;
> class my.test.thing { // OK to explicitly name?
> void my.test.thing.method() {} // How about this?
> }
> // or this, in the same source file? (I doubt it)
> class some.other.package.foo {
> }
You can use fully qualified class names anywhere a class name
is expected. This means that your first example would work,
the method declaration would fail, so would the last example,
because the class name is not properly qualified.
> Is it possible for a class and a package to have the same name?
> Is it meaningful to import a package (as opposed to all the
> classes in a package)?
Unfortunately yes. This makes allows for possible confusion between
package and class names. However, packages are never explicitly
refered to, so it really isn't a problem.
Have fun,
Arthur van Hoff (avh@eng.sun.com)
http://java.sun.com/people/avh/
Sun Microsystems Inc, M/S UPAL02-301,
100 Hamilton Avenue, Palo Alto CA 94301, USA
Tel: +1 415 473 7242, Fax: +1 415 473 7104
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com