1

i am beginner to java . i am having issue with importing a class to the package file from outside the package

enter image description here

here i am having a package named mypack and inside it there is class file named abc. outside the package i have an another class file named pacl and i want to import class from pacl to the abc(which is inside the package). does java support this . i have searched the web and haven't got the answer

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
SHANIL t s
  • 41
  • 1
  • 9
  • Check out the answer to this question https://stackoverflow.com/questions/2030148/whats-the-syntax-to-import-a-class-in-a-default-package-in-java#:~:text=You%20can't%20import%20classes,type%20from%20the%20unnamed%20package. – Seeker Sep 02 '20 at 10:05

1 Answers1

3

Your pacl class is in the default package, and therefore can't be imported. You'll need to put it in a package if you want to import it to classes in other packages. In fact, you shouldn't be using the default package if at all possible, specially if you have multiple classes in various packages.

JustAnotherDeveloper
  • 2,061
  • 2
  • 10
  • 24