simpatico
simpatico

Reputation: 11087

Can Linux Java Developers create classes of names different only by case in the same package?

In Java class names are supposed to be case sensitive, so Java shouldn't have a problem with it. The problem should come from case-insenstive file systems, many linuxes not included.

Upvotes: 2

Views: 365

Answers (3)

gorlok
gorlok

Reputation: 1155

You can't by official naming convention. You must name your class using CamelCase, starting with a Uppercase.

In Linux you can do it, but it's a very bad idea. Your resulting code/classes will not be portables.

And you will found problems with source control tools, IDE's, another OSes, some JVMs, etc.

For example: you can use non-english (utf8) characters for your classes. I have seem classes with Spanish names (with characters like ñ, Ñ, á, à, etc). Soon or later it will be a problem, because not every filesystems works with utf8 (some uses ansi-like, ascii, or something else). Very long names can be trouble too. Some filesystems have limits on name length like ISO-9660 filesystems, some FAT versions, etc.

Stay in the safe path :)

Upvotes: 0

esaj
esaj

Reputation: 16035

I tried this on Linux, and I could create different classes with same name but different capitalization and use them. As I have no Windows-machine, I can't test how this would work (or if it works at all) in Windows (or any other OS for that matter), but I would not encourage naming classes like this.

Upvotes: 3

Oded
Oded

Reputation: 498972

What are you talking about?

The class name is not derived from the filename but from the contents of the file (i.e. the class name as it appears in the file).

Whether the filesystem or OS treat filenames as case insensitive is irrelevant.

Upvotes: 1

Related Questions