This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Just that, nothing else. In my Main file, I had this:
All 3 files are in the same directory (folder). I tried to compile this (in NetBeans 6.8) but I got an error about the class DesktopOrganizerForm not being declared. So then I tried all kinds of import statements, including obvious stuff like:
Then I gave this a try, which did work:
I put this line in all 3 files, and suddenly NetBeans seemed to realize that the classes in one file should be available to classes in the other files. But surely this is not the right way forward? What happens when I have 50 files, or 100 files? There will come a point when I want more than 1 package. What is the right way to do this, other than putting all files in the same package?
Are you asking how packages should be organized? Heck, with all the libraries and whatnot used in any non-trivial program there might be a hundreds or thousands of packages, and if you're not doing .* imports a class might have two dozen import statements (but it all depends). I just keep the imports folded, let the IDE manage them, and almost never have to think about it.