Classes in java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Classes in java

Is there anyone here who codes in java using this anacode IDE (on Android). If so, how do you manage to link classes to codes? It doesn't work for me.

13th Feb 2020, 3:03 PM
SolomonDavid Akesoba
SolomonDavid Akesoba - avatar
5 Answers
+ 2
Both should be in the src folder and if you also added a package name, then in the subfolder of the package.
15th Feb 2020, 8:04 PM
Tibor Santa
Tibor Santa - avatar
+ 1
There is a documentation here how to build an application with multiple files. http://www.anacodeide.com/article?pagename=build_standalone_java_r1600 You are supposed to create a java project and then you can add new files (classes) in the same folder (normally the src subfolder in the project, and inside it the folder dictated by the name of your custom package.)
14th Feb 2020, 6:59 PM
Tibor Santa
Tibor Santa - avatar
+ 1
Tibor Santa yeah. I tried doing that. Didn't work. If I insert the class inside the file that has the main method (like we do in SL), it tells me that it's supposed to be in another file. When I try accessing the class from another file (the process of which I can't understand) it still throws an error.
15th Feb 2020, 8:37 AM
SolomonDavid Akesoba
SolomonDavid Akesoba - avatar
+ 1
Tibor Santa same folder? The folder where the src folder is or in the src folder?
15th Feb 2020, 7:28 PM
SolomonDavid Akesoba
SolomonDavid Akesoba - avatar
0
Well I cannot comment on your own code if you don't share it, I can show you how it works for me. In the Anacode app I created a new project (JavaTest) which has class JavaTest with the main() method. Then I created a Student.java file in the same folder. As long as they share the same package and are located in the same folder, they are able to interact even without any import statements. See these screenshots how my code looks, and it does compile and prints '12' https://ibb.co/2nWHv6r https://ibb.co/qDn5Wqn
15th Feb 2020, 1:19 PM
Tibor Santa
Tibor Santa - avatar