Accessing class of a Package

import testpackage.*;

publicclass TestNonPackagePackageAccess{

publicstaticvoid main(String args[]){

testpackage.TestPackageNonPackageAccess tPNP =new testpackage.TestPackageNonPackageAccess();

System.out.println(tPNP);

String classDesc ="Class without Package declartion";

System.out.println(classDesc);

}

}

In the above code I have:

import testpackage.*;

Even after importing the package I once again have to explicitly use

testpackage.TestPackageNonPackageAccess tPNP = newtestpackage.TestPackageNonPackageAccess();

without the package prefix i get an error. then why do we use imports in the first place.

[1081 byte] By [hemanthjavaa] at [2007-11-27 7:43:07]
# 1
What exactly does the error say?
petes1234a at 2007-7-12 19:23:55 > top of Java-index,Java Essentials,Java Programming...
# 2

Dude, you have two TestNonPackagePackageAccess classes--this one which is in no package and the one in testpackage.

One of two things is happening: There's an ambiguity, and the compiler doesn't know which one you mean, or the compiler is assuming the "local" one, but that one doesn't have the constructor you're calling.

Like the man says: Paste in the complete, exact error message. Just saying "there's an error" tells us nothing.

jverda at 2007-7-12 19:23:55 > top of Java-index,Java Essentials,Java Programming...