开发者

Difference between import in java and objective C

开发者 https://www.devze.com 2023-01-18 08:43 出处:网络
can some tell me the difference between the import we use in java and the one in objective开发者_如何学编程 C?

can some tell me the difference between the import we use in java and the one in objective开发者_如何学编程 C?


  • In Java, import long.package.name.Foo; tells the compiler that any time Foo appears as aa class name in the current source file, it really means long.package.name.Foo - so all import really does is allow you to write shorter source code. Finding class definitions is done via the convention of having class names match file names and package names match directory hierarchies.

  • In Objective C, an #import statement is actually replaced with the contents of the imported file by the preprocessor, unless that file has already been imported (this is the difference between #import and the older #include directive).


#import is a variant (that checks for duplication) of #include, which just results in the contents of the included file being pasted in your source file.

Java's import statement tells the compiler where to look for classes (and other things) that are not qualified by their full name in the source code.

0

精彩评论

暂无评论...
验证码 换一张
取 消