Hi Mohit,
In short, there's a lot of difference.
The
Java import statement is effectively just a declaration - it doesn't include a file. It's function is to let the compiler know where (i.e. in which package) to locate the API for the imported class. It's also a convenient shorthand so that you don't have to include the full package specification each time you refer to a class. I think it may also be used, indirectly, by the JVM to determine which classes to load at start-up. Perhaps someone else can clarify that.
The C/C++ #include directive actually includes a file, usually a header file, inline as the C source file is compiled.
Java has little or no need for most of the features usually provided in a C/C++ header file. Consider these:
Java is platform independent and therefore has little use for preprocessor directives such as #define, #ifdef, etc.Lists of global constants can be encapsulated as static final declarations in an interfaceJava doesn't have macros, but the performance gains offered by these in C/C++ are mitigated by the use of inlining by Java compilersYou don't need to define function prototypes in Java as the compiler copes without forward definitions (two-pass compilation??) I hope this adequately answers your question.
Jules