wood burning stoves 2.0
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Package name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Package name " Watch "Package name " New topic

Package name

pinky yadav
Ranch Hand

Joined: Jun 17, 2002
Posts: 44
Check out the following code from JLS doc
package Vector;
class Mosquito { int capacity; }
package strange.example;
import java.util.Vector;
import Vector.Mosquito;
class Test {
public static void main(String[] args) {
System.out.println(new Vector().getClass());
System.out.println(new Mosquito().getClass());
the output is :
class java.util.Vector
class Vector.Mosquito
why there is no conflict in name ??
Juanjo Bazan
Ranch Hand

Joined: Feb 04, 2002
Posts: 231
In order to get a conflict in name, you need two different classes with the same name.
This is not the case, you are refering to Vector and Mosquito classes...no problem.
pinky yadav
Ranch Hand

Joined: Jun 17, 2002
Posts: 44
Yes but if i try with 1.3 it gives a compile time error but not with 1.4
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
One Vector is a package and the other is a class, no problem for the compiler; but confusing for non- walking-compiler humans , as me.
The compiler of sdk 1.3 did not match JLS as well as version 1.4 does.

SCJP2. Please Indent your code using UBB Code
I agree. Here's the link: http://aspose.com/file-tools
subject: Package name
jQuery in Action, 3rd edition