+ 1
Importing packages in java
if you import all the packages instead of the only the ones that your program requires are the only effects speed of execution and memory requirements?
9 Respuestas
+ 16
@[Andrew], When learning basics in Java, we use Scanner class of java.util package, so few people import the package like java.util.* , while few does like java.util.Scanner;
I think there is a difference of execution time between both statement of importing all classes of util package,
and importing a single Scanner class.
+ 17
There is something called #include (Preprocessor) which is used to include the whole header file, despite including only those which we need in our program,
To overcome this issue, for the purpose of improving execution speed, reducing response time etc, Java introduced "import" keyword, which then start to use to import only those packages or subpackages or classes which are needed in our program.
So, it is obvious that if you import all the packages you know, the program will surely die because you are conflicting the rules of import.
+ 16
@Very hard, I meant about the execution speeds between the two of cases I stated above.
+ 16
@Very hard, Oh man!! 😂😂😂 I have never seen a guy doing that much precise work.
And yeah, the difference will be in ms(miliseconds), if it is.
+ 6
@Sachin Artani
Ha ha if that. I think "nope"
Unless if you use too much and so much class
Or silly like I do
(I use java.lang.System.out.print to just print "Hello world" -_- oh yeah not end yet.I'm crazy more I import java.lang.System -_-)
+ 5
Difference is they import whole class of java.util
+ 4
I think not much...
Cus we can use another class without import it
+ 2
You would think so. but java includes the import option with import java.util.*; So they must expect it to be used sometime.
0
as many as you want