ClassgetSimpleName () vs hardcoding class name in java?
If you redefine your class name later, the hardcoded name will not change, but getSimpleName()
will always indicate the current class name.
You should always remember the places to change if you are hard-coding the class name when updating the class name.
Not just the Class Name, avoid hardcoding AMAP. Otherwise, it really increases the cost of maintenance.
source to share
java.lang.Class.getSimpleName () returns the simple name of the base class as given in the source code. Returns an empty string if the base class is anonymous.
since Kocko said that Class.getSimpleName () will always return the name to you without any typos, while you can hardcoding the typo on the class name. "and as sα΄Κα΄sΚ α΄α΄α΄α΄ said," When you rephase your class name later, the hardcoded name will not change and getSimpleName () always gives you the current class name. "so you can keep making changes and refracting the class without worrying about creating an error in the dependent classes.
source to share