本来我也是分情况讨论的,但后来绕晕了而且还有数组越界异常,就全删了,然后想起来直接利用库函数正则表达式匹配把,就去复习了一下 public class Solution { public boolean match(char[] str, char[] pattern) { return new String(str).matches(new String(pattern)); } }