개발

    [Java] length, size()의 차이

    [Java] length, size()의 차이

    🐤 length array.length -> 배열의 길이 구할 때 사용 int[] array = new int[10]; System.out.println(array.length); // 출력 : 10 🐤 size() list.size() -> collection 타입의 사이즈를 구할때 필요하다.(ArrayList) List l = new ArrayList(); l.add(1); l.add(2); System.out.println(l.size()); // 출력 : 2