#include directive makes the compiler go the C/C++ standard library and copy the code from the header files into the program. As a result, the program size increases thus wasting memory and processor's time.
import statement makes the JVM go to the Java standard library, execute the code there and substitute the result into the program. Here, no code is copied and hence no waste of memory or processor's time. So import is an efficient mechanism than #include.
No comments:
Post a Comment