Skip to content
Advertisement

Tag: patternsyntaxexception

how pattern syntax exception works

how do I use the following statement in try n catch block to chk if the name is valid and display error msg if any? and how to use PatternSyntaxException Answer You don’t need a try…catch to check if the name is valid. The line you wrote: NAME_PATTERN.matcher(name).matches() returns a boolean, true if it matches and false if it doesn’t.

Advertisement