I\'d like to test if a string ends with a a digit. I expect the following Java line to print true. Why does it print false?
System.out.println(\"I end with
System.out.println("I end with a number 4".matches(".*\\d")); // prints true
or
String s = "I end with a number 4"; System.out.println(Character.isDigit(s.charAt(s.length()-1))); // prints true