+ 3

Can you have multiple source files for a program.

Hi everyone, how would you post a Java program with three classes on SoloLearn? Normally Java wants each class in a separate .java file. I usually have a source directory for all the .java files in a project. How would I post a Java program that has three classes and three .java files? The main class imports the two other classes it uses. does import on SoloLearn's Java playground support private imports for different parts of your program?

7th Oct 2018, 6:22 AM
Rick Shiffman
Rick Shiffman - avatar
2 Respostas
+ 4
Sololearn doesn't allow multiple source program, then you should pack all into a single file. obviously, it's not a proper way to write code in Java
7th Oct 2018, 7:17 AM
Xavier Heugue
Xavier Heugue - avatar
+ 1
There's also Reflection / dynamic class loading (not personally tested): http://tutorials.jenkov.com/java-reflection/dynamic-class-loading-reloading.html ...if you reframe the "issue" as "how to work with the limited resources available in my Internet-of-Things-like" environment.
7th Oct 2018, 4:04 PM
Kirk Schafer
Kirk Schafer - avatar