Board index » jbuilder » How to import classes that are in the "default" package?

How to import classes that are in the "default" package?


2004-06-11 10:02:10 PM
jbuilder9
class X belongs to package A, A want to use class B , B does not
belongs to any package, the how to import B?
package A;
import B // ???
import default.B//???
import ???
class X {
}
TIA
Best Regards.
 
 

Re:How to import classes that are in the "default" package?

Chris wrote:
Quote
class X belongs to package A, A want to use class B , B does not
belongs to any package, the how to import B?

package A;

import B // ???
import default.B//???
import ???

class X {

}

TIA
Best Regards.
In JDK 1.4 it is not possible. You MUST put your classes in packages if
you plan to import them. There was a "hole" in the JDK specification
that used to allow this, but as of JDK 1.4 the specification has been
tightened up.
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
www.google.ca/advanced_group_search
Other Newsgroup Searches:
www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
www.visi.com/~gyles19/fom-serve/cache/1.html
 

Re:How to import classes that are in the "default" package?

Thank you , Olson.
I also found the infomation finally at :
java.sun.com/j2se/1.4/compatibility.html
excerpted from Java 2 Platform Compatibility with Previous Releases:
The compiler now rejects import statements that import a type from the
unnamed namespace. Previous versions of the compiler would accept such
import declarations, even though they were arguably not allowed by the
language (because the type name appearing in the import clause is not in
scope). The specification is being clarified to state clearly that you
cannot have a simple name in an import statement, nor can you import from
the unnamed namespace.
To summarize, the syntax
import SimpleName;
is no longer legal. Nor is the syntax
import ClassInUnnamedNamespace.Nested;
 

{smallsort}