The major difference would be that in C++ the actual file is included. The only advantage is that you could modularize and compile the code seperately. The executable code size will be as much as if you put all the files together and compiled it together.
But in Java, the technology itself is different. The Java files are compiled individually and the class files are not big at all, even if you import so many classes. The actual classes are loaded when you run the code.
So its a bit interpretation in Java. So, you might end up getting smart code in Java. For example if you have an empty loop for a million times, the Java will not even execute it even once, as the interpreter (unlike the compiled executable. Of course there are smart compilers for c that can take care of some things like this, but not as many things as java can do) will generate on the fly code.
Hope it answers.
What is different between c++ include and java import?
A C/C++ include statement lists a file which replaces the include statement in the source file. The contents of this included file can be anything, but are usually constants and function "declarations".
Java imports are used to help resolve symbol names that are not fully qualified in the source itself. As an example:
import java.util.*; allows one to abbreviate the class java.util.Map as "Map". Without the import statement, the fully qualified name would have to be written.
Java does not require explicit declarations before a symbol can be used. Therefore C++ includes and java imports are completely different.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment