May 26, 2002 - Handling Non-Qualified Name Collisions
![]() |
May 26, 2002 Handling Non-Qualified Name Collisions Tips: May 2002
Yehuda Shiran, Ph.D.
|
USA.Florida namespace defines the class Head, which includes the Governor function:
package USA.Florida {
public class Head {
static var Governor : String = "Bush";
}
};
The following code defines a local class and a local function. They are named by the same names as above:
class Head {
static var Governor : String = "Davis";
}
Now, we import USA.Florida, conflicting the definition of Head and Governor:
import USA.Florida;
The class Head.Governor is non-qualified, because there is such a class in the USA.Florida namespace, and there is also a class by the same name in the local namespace. When you print the value of the non-qualified function Head.Governor, the local value will override the imported name. The code:
print(Head.Governor);
will yield the following output:
Davis
To learn more about JScript .NET, go to Column 109, JScript .NET, Part III: Classes and Namespaces.


Find a programming school near you