public static void main(String[] args) { String s= "U18A1组"; char[] chars = s.toCharArray(); for (int i = chars.length-1; i >=0 ; i--) { if ((chars[i]+"").getBytes().length==1 && 'A'<=chars[i]&&chars[i]<='Z'){ System.out.println(chars[i]); break; } } }