How is import done in Java?

后端 未结 8 1266
终归单人心
终归单人心 2020-11-29 19:57

For instance

import org.apache.nutch.plugin.Extension,

though used many times,

I\'ve no much idea what is done essentially.

8条回答
  •  萌比男神i
    2020-11-29 20:31

    you can't have a directory named org.apache as a package. the compiler won't understand that name and will look for the directory structure org/apache when you import any class from that package.

    also, do not mistake the Java import statement with the C #include preprocessor instruction. the import statement is, like they've said, a shorthand for you to type fewer characters when referring to a class name.

提交回复
热议问题