2009-08-12 4 views

Trả lời

14

Tạo đối sánh và sử dụng find() để định vị nó trong trận đấu tiếp theo.

15

Đây là mẫu mã:

int countMatches(Pattern pattern, String str) { 
    int matches = 0; 
    Matcher matcher = pattern.matcher(str); 
    while (matcher.find()) 
    matches++; 
    return matches; 
}