0
Is there a way to define and implement Java classes in separate files? Like in C++ where we would have header files (.h)?
3 odpowiedzi
+ 4
While Java allows you to put multiple classes in the same file, only one of them can be public. This is not the way to build bigger apps, but a limitation of SoloLearn.
Normally you would write each class, interface, enum in a separate file, and organize them in packages, which are represented by subfolders in your project. When you have many files in the project, you would organize them based on the functionality or layer of the architecture (core business logic or "domain", interfaces, persistence, frontend/ui...)
0
Thanks man... This seems really helpful!