0

Is there a way to define and implement Java classes in separate files? Like in C++ where we would have header files (.h)?

4th Apr 2020, 3:10 AM
Barabbas
Barabbas - avatar
3 Answers
4th Apr 2020, 3:18 AM
Kevin ★
+ 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...)
4th Apr 2020, 6:12 AM
Tibor Santa
Tibor Santa - avatar
0
Thanks man... This seems really helpful!
4th Apr 2020, 3:20 AM
Barabbas
Barabbas - avatar