Most appropriate place for bounds checking - constructor or setter?
问题 Still relatively new to Java and I'm wondering which is the better way to handle this. I have a class constructor that takes a few parameters, and also in this class are public getters and setters: private String name; private Float value; public MySampleClass(String theName, Float theValue) { setName(theName); setValue(theValue); } public void setName(String n) { this.name = n; } public value setValue(Float v) { this.value = v; } I'd like to do some bounds checking on this Float. It seems