Separate files for class definition and declaration in Java

I am a C programmer who is currently learning Java. I want to know if OOP in Java follows the same principle as the class definition and declaration separated from C, that is Put them all in separate files I have seen the Internet, including the Android Developer website, and all the code I encounter has simultaneous definitions and declarations

Is this just one of the differences between C development and java development, or is it the way I've been looking for to limit the complexity of the code they publish on the Internet? I've seen declarations and definitions in some C documents, although I know it's not a good practice

Solution

There is a practical reason for separating declarations in C, which allows source files to be compiled separately There is no such need in Java (because all content is compiled into bytecode separately), so it is not allowed

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>