I have read at the sun site that Java runtime system automatically imports three entire packages: The default package (the package with no name) The java.langpackage The current package What does it mean by the default and the current pacakge?
The definition of "current" directory is dependant on the host system. In windows, the current directory IS the default (un-named) package and is the directory that you are sitting in when you compile. Therefore if there is any other class file in the same directory with you, you can access it without explicetly importing it. (edited by Cindy to change "package" references to "directory" references )
[This message has been edited by Cindy Glass (edited May 17, 2001).]
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joined: Feb 06, 2001
you mean to say that the current and default package is same.
I don't understand the meaning of current package as you. But for me if you have a class in the package com.stuff you do not need to import classes from this package inside your code. Thus for me the current package is the package where your class is declared. For default package it seems to me that it is classes without package definition. If i'am wrong tell me what i miss ------------------ Benjamin l�onard evisor
Joined: Sep 29, 2000
You are correct, the current package is the one that the class is in. I intended to talk about the current directory and completely muddled it. Thanks for pointing it out. From the JLS 7.4.2 Unnamed Packages
An implementation of the Java platform must support at least one unnamed package; it may support more than one unnamed package but is not required to do so. Which compilation units are in each unnamed package is determined by the host system. In implementations of the Java platform that use a hierarchical file system for storing packages, one typical strategy is to associate an unnamed package with each directory; only one unnamed package is observable at a time, namely the one that is associated with the "current working directory." The precise meaning of "current working directory" depends on the host system. Unnamed packages are provided by the Java platform principally for convenience when developing small or temporary applications or when just beginning development.