Comma Constant in Internal Library
I Want to Use Constant Char/String Comma (,) in My Code. Where I Can Find Static Final Variable in Standard Library? If There Is Not Such a Place, Can You...
I want to use constant char/string comma (,) in my code.
Where I can find static final variable in standard library? If there is not such a place, can you point me popular external library for that?
EDIT: I don't want to create my own constant, I want to use it from JDK (or external library if it not exists)
3 Answers
What would be the benefit of depending on an external library for just a constant? If your not using code from that library I would advise to define the constant in your own project.
If you use the comma-constant all over the place in your code try to find a common interface/class and define the constant in that interface/class.
If there is no common interface/class create an enum with a logical name. Do not create a class or interface just for wrapping a constant.
If you need the comma-constant in a single class declare it in that class. (either protected or private).
See also What is the best way to implement constants in Java?
But if you really want to use a third-party library, you might want to look at:
Did you mean this :
public final char CH = ',';
You can use this:
import sun.tools.java.Constants;
Constants.opNames[Constants.COMMA]