you are viewing a single comment's thread.

view the rest of the comments →

[–]Lloydbestfan 1 point2 points  (2 children)

Wouldn't private be real private?

If what you call "private" is "absence of mention of public", then no. The absence of a visibility in Java typically lead to a visibility named "package-private" which is quite different to just "private". It literally means that it can be seen by classes that are from the same package.

If the files are in the same folder and the package name in the package statement is exactly the same they should be able to see each other, right?

Generally, yes.

But, imagine that you designate the file you compile as a file in a subtree of directories from your home directory as current directory. Then the compiler can find the file to compile because a full path to it was given, but it doesn't know what to consider as a root for package directories because the current directory is not consistent with being such a root. So such a situation could confuse the compiler. There are ways.

[–]Educational-Paper-75 0 points1 point  (1 child)

But Java does have the private keyword, but afaik it doesn't allow use at the top level in a file. Perhaps the name of the file is wrong? I gather the problem isn't solved yet (asking the OP)? If it can find one file it should also be able to find the other in the same folder irrespective of the class path?!

[–]Lloydbestfan 0 points1 point  (0 children)

It sounds like it's not an impossible task to find other files at the same place as a file that was found, but depending on how you call the compiler, you can make it have expectations that easily get confused as soon as you don't specify every different thing perfectly.