# [JAVA] 배열의 유사도

> 두 배열이 얼마나 유사한지 확인해보려고 합니다. 문자열 배열 s1과 s2가 주어질 때 같은 원소의 개수를 return하도록 solution 함수를 완성해주세요.

---

### ◇ 내 답변

```
class Solution {
    public int solution(String[] s1, String[] s2) {
        int answer = 0;
        

        for (String el: s1) {
            for (String el2: s2) {
                if (el.equals(el2)) {
                    answer += 1;
                }
            }
        }
        return answer;
    }
}
```

1. JAVA에서는 String을 비교할 때 ==을 사용하면 안 돼... equals를 사용해야해.. 왜냐면 참조값이니까...

For the site tree, see the [root Markdown](https://slashpage.com/%EB%AC%B4%EB%91%A5-rypb2.md).
