posted 8 years ago
When the compiler sees "URLConnection" it recognises it as a type (because of its context in the code) but doesn't know where to find it. So the import statement tells it where to look. There is no difference in memory requirements between the two styles, but the 1st option is preferred because
There is less risk of collisions (eg Timer; there are two Timer classes available) It is easier to review the code and see what imports have been used.
Jesper de Jong