I recently started a project in Java, that contains a class called System
. This class (Luckily) contains methods for output management, so in the rare cases where I need to use the System.
methods (Or the System
object in general) I just reference it as java.lang.System.
. I believe that this could be looked down upon, as System
could be looked at as a reserved name. I currently am in the beginning stages of this program, and could change it accordingly quickly, as there are little calls to the class itself.

- 994
- 1
- 9
- 18
-
There is nothing wrong with that. `System` is not a reserved word obviously. Just because a popular class is named `System` doesn't mean you can't or shouldn't create your own *if that's the best name your class could reasonably have* – Kon Mar 21 '15 at 02:08
-
Thank you. This is helpful, but I will reconsider my overall program structure for the good of this program's future. – DripDrop Mar 21 '15 at 02:11
-
2I would really try to avoid shadowing anything from `java.lang`. – Elliott Frisch Mar 21 '15 at 02:20
-
2The popularity of the class `java.lang.System` will make it more difficult for other people to make sense of your code if they are not first familiar with how your code works. Given the number of issues people have `java.util.Date` and `java.sql.Date` I'd recommend against it personal and try and see if you can name it more appropriately. That said, if you're comfortable with it, there's nothing really stopping you. There's also the concern that `java.lang.*` is imported automatically... – MadProgrammer Mar 21 '15 at 02:26
2 Answers
While it's not illegal, you don't want to do this. If I were the next person working on your code, the first thing I would do is try to remove "java.lang
" from "java.lang.System
" and then get miffed when it wouldn't compile.
The idea is to go toward brevity and only write what you need to write, while making sense of it all for the next person. It's more an art than a science.
You could always name it something like ProjectnamehereSystem
or OutputManager
or something to that effect.

- 8,575
- 10
- 55
- 80
-
Thank you. That structure flaw was on me, and I will find a way to fix it. – DripDrop Mar 21 '15 at 12:22
I would not create something so similarly named as an important class. While everything is easy to edit, you may be able to keep up with all the changes you are making.
But when the project evolves things will get messy and complex. I would suggest naming it something else that can be easily distinguished.

- 66
- 5
-
Thank you. I will reconsider my program structure, as I have figured out the messiness of my code. This was helpful. – DripDrop Mar 21 '15 at 02:14