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.
There's something I don't understand about import statements, or maybe I'm just missing something really obvious. Why would a class have to be imported specifically, if the * has already been used with its parent package? For example, why would I have to say: import java.awt.*; import java.awt.event.*; Shouldn't event already be imported with the first line, because of the *? I get compiler effors complaining of this problem, and it's easy enough to just fix them with another, more specific import statement. But I never know from the outset whether I've done my imports correctly, and there seems to be no rhyme or reason to how this works. How does it work? What's going on here? BTW, it's really cool how IntelliJ Idea generates import statements for you... ...but I still wanna know!
Try to think of packages as folders (directories) in a tree structure. That is really all they are and as silly as it may seem, you do have to import both java.awt.* and java.awt.event.* because the import only imports the classes in that directory and does not traverse the sub-directories. Hope this clears it up
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher