The sample code:
String test = \"Z\"; Pattern pt = Pattern.compile(\"[0-9]*\"); Matcher mc = pt.matcher(test); System.out.println(mc.find());
because Z is not in the class [0-9]*(This should matches only the digits between 0 to 9 check the demo regex), to match Z it should be in the class [0-9Z]* (demo regex)
Z
[0-9]*
0
9
[0-9Z]*
Pattern pt = Pattern.compile("[0-9Z]*");