on-internet
← Community

boolean validating String length before appending char at the end

Stack Overflow ·

I was given an assignment, see for requirements: Class InputElement: Properties: private int maxLength> private String value Constructor: accepts int maxLength and initializes value to an empty string. Methods: validate(): return true if value length is between 1 and maxLength getValue(), setValue(char c): the setter appends c to value or removes the last character if c is '/'. Use the validate method tocheck if the to be added value is valid and will only add the character to the value if it is valid. and here is the code that I made for it: public class InputElement { private int maxLength;

Comments

Sign in or sign up to comment and upvote.

No comments yet.