If I import and use a single class from another package, will it include all files from the package?
for example, if I use only a single class from the mylibrary package which is called MyFunctions, will the following include all classes or not?
import my.example.mylibrary.*;
compared with:
import my.example.mylibrary.MyFunctions;
No
The import does not include anything into your program.
Classes are loaded when they are used, and not before. So the only thing the
importis to help you to avoid typing the whole class name.For instance it is much better to type ( and to read ) :
than
And yet, they perform exactly the same.
Also, bear in mind that using
vs.
Have exactly the same performace, except the firs it faster ( and dirtier ) and the second is clearer.
Always!! use the second form in production and/or when someone else needs to see your code.