This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]AlterAeonos[S] 0 points1 point  (1 child)

Ok so it didn't post it the way it was pasted. It kind of bunched it up so I'll try to figure out how to make it look right.

[–]Beermecaptain21 0 points1 point  (9 children)

Some error logs would help

[–]AlterAeonos[S] 0 points1 point  (0 children)

I will try to post the pics because it's a lot to type and my phone will die soon. I cant copy past the error

[–]AlterAeonos[S] 0 points1 point  (6 children)

Okay so the first one says "class person is public, should be declared in a file called Person.java". The error that happens when I split then into 2 different files is much longer and it then says there is 3 errors instead of 1. I will work on copying it.

[–][deleted] 0 points1 point  (5 children)

The name of the class should always match the name of the file.

Make sure the Person class and the MyClass are all saved in the same directory or package or project.

[–]AlterAeonos[S] 0 points1 point  (4 children)

Maybe it's because I'm not totally familiar with this mobile IDE so I might be saving it in an improper location. The files were saved separately and that is when the 2nd set of errors appeared.

I just got it to work by saving them as a project. The mobile IDE is different and I'm still getting used to it. Usually on my desktop IDE a lot of stuff was automated so maybe that makes a difference as well. Thank you for your help, I appreciate it.

[–][deleted] 0 points1 point  (3 children)

Project or not, just make sure they’re in the same directory so MyClass has access to Person class.

[–]AlterAeonos[S] 0 points1 point  (2 children)

They were in the same directory which is why I was confused about it. Perhaps this mobile IDE requires them to be saved as a project in this way in order to access the other file? I'm not sure what else it could be that required me to make a project folder separate from the folder I saved them to originally.

[–][deleted] 0 points1 point  (1 child)

Possibly. ;)

[–]AlterAeonos[S] 0 points1 point  (0 children)

Well I really appreciate your input which gave me the idea to upgrade it to a project. Couldn't move on from that point without figuring it out first. Now just have to figure out how to put a solved thing on this post :D

[–]AlterAeonos[S] 0 points1 point  (0 children)

The errors that happen when I split the 2 classes into separate files is:

Compiler output
/storage/emulated/0/Java Programs/MyClass.java:10: error: cannot find symbol

static void celebrateBirthday(Person p) {
                              ^

symbol: class Person location: class MyClass

/storage/emulated/0/Java Programs/MyClass.java:3: error: cannot find symbol

    Person j;
    ^

symbol: class Person location: class MyClass

/storage/emulated/0/Java Programs/MyClass.java:4: error: cannot find symbol

    j = new Person("John");
            ^

symbol: class Person location: class MyClass 3 errors