This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

import statements  RSS feed

 
Allion Salvador
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, everyone! I'd like to ask if you can stick a huge import statement like this:
and so on...
Thanx!
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. You need to identify a package or type.

http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.5
 
Marilyn de Queiroz
Sheriff
Posts: 9080
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.awt.* != import java.awt.color.*

import doesn't read subpackages.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marilyn de Queiroz:

import doesn't read subpackages.


Marilyn is 100% correct, but I should point out that formally, Java doesn't have "subpackages." It's a perceptual thing only. We humans see java.awt and java.awt.color, and we sense a relationship. But Java doesn't recognize that relationship at all: there's absolutely nothing that ties these two packages together (including the behavior of the import statement.)
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... absolutely nothing ... except that the assertion mechanism (introduced
in 1.4) has flags for turning on or off assertions:

this, according to the assertion documentation enables assertions in the named package and any
subpackages
. Did I read that correctly? Subpackages?
[ November 18, 2005: Message edited by: Jeff Albrechtsen ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ummm, the term "subpackage" has appeared in all three editions of hte JLS so far. They don't seem to have provided a formal definition, but there are examples and context which make the concept fairly clear. We don't actually do much with subpackages - the concept exists mostly for convenience when stating other rules. Such as, for example, "...an import statement cannot import a subpackage, only a type."
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I guess I'm all kinds of wrong: I did forget about the assertion thing. Prior to that, however, I'm fairly certain that the only use of the term was, as in the case that Jim points out, to mention that they get no special treatment by import or by the access control modifiers.
 
Allion Salvador
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok! I got it!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!