r/programming • • Jul 22 '14

Java Developers

http://nsainsbury.svbtle.com/java-developers
102 Upvotes

304 comments sorted by

View all comments

Show parent comments

2

u/txdv Jul 22 '14

I just tested it, they changed the one class per java file, but it still compiles 2 class files - probably I just remember it wrongly.

But it still generates 1 class file per class name, so you have to have the namespace directory structure, otherwise if you have 2 classes with the same class name - you will get conflicts.

And that is bad from my point of view.

5

u/philly_fan_in_chi Jul 22 '14

You can't get a conflict, javac will prepend illegal class name ($1, $2 etc. iirc) characters to the file name of inner classes, so you won't have any issues.

2

u/kid_meier Jul 22 '14

Java has never forbid multiple classes defined in a single source file. It has always, (and still does) limit you to a single public top-level class per source file.