Files
2nd/10_Wiki/Dev/Topic_Java/Java_ArrayList.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

4.1 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
java-arraylist Java ArrayList Programming_Language draft conceptual
자바 ArrayList
B 0.9 2026-07-04 2026-07-04
java
programming
w3schools
collections-framework
arraylist
https://www.w3schools.com/java/java_arraylist.asp

Java ArrayList

🎯 한 줄 통찰 (One-line insight)

Storing primitives in an ArrayList requires their WRAPPER classes, not the primitives themselves — ArrayList<Integer> works but ArrayList<int> doesn't compile, because ArrayList elements are objects and Java's primitives (int, boolean, char, double) aren't objects; each has an object wrapper (Integer, Boolean, Character, Double). [S1]

🧠 핵심 개념 (Core concepts)

  • ArrayList — a resizable array; unlike plain arrays, elements can be added/removed at any time. [S1]
  • Core methodsadd(), add(index, value) (insert at position), get(), set(), remove(), clear(), size(). [S1]
  • Wrapper classes required for primitivesInteger for int, Boolean for boolean, Character for char, Double for double. [S1]
  • Collections.sort() — sorts an ArrayList alphabetically (Strings) or numerically (numbers). [S1]
  • var keyword (Java 10+) — infers the type, avoiding repeating ArrayList<String> on both sides. [S1]
  • List-typed variable holding an ArrayListList<String> cars = new ArrayList<>(); — valid since ArrayList implements List; offers flexibility to swap implementations later. [S1]

📖 세부 내용 (Details)

  • Basic creation and add: ArrayList<String> cars = new ArrayList<String>(); cars.add("Volvo"); cars.add("BMW");. [S1]
  • Insert at index: cars.add(0, "Mazda"); // insert at the beginning. [S1]
  • Access/modify/remove: cars.get(0); cars.set(0, "Opel"); cars.remove(0); cars.clear(); cars.size();. [S1]
  • Loop with index or for-each: for (int i = 0; i < cars.size(); i++) { System.out.println(cars.get(i)); } or for (String i : cars) { System.out.println(i); }. [S1]
  • Wrapper class for numbers: ArrayList<Integer> myNumbers = new ArrayList<Integer>(); myNumbers.add(10);. [S1]
  • Sorting: Collections.sort(cars); // alphabetical or numeric sort. [S1]
  • var keyword: var cars = new ArrayList<String>();. [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

  • 원시 타입 저장 불가: ArrayList의 요소는 객체이므로 int/boolean 등 원시 타입은 직접 저장할 수 없고 반드시 래퍼 클래스(Integer, Boolean 등)를 사용해야 함이 명시됨. [S1]

🛠️ 적용 사례 (Applied in summary)

현재 발견된 실제 적용 사례가 없습니다 — 문자열/숫자 리스트를 Collections.sort()로 정렬하는 것이 실전에서 자주 쓰이는 패턴이다. [S1]

💻 코드 패턴 (Code patterns)

Sorting an ArrayList with Collections.sort() (Java):

import java.util.ArrayList;
import java.util.Collections;

ArrayList<String> cars = new ArrayList<String>();
cars.add("Volvo");
cars.add("BMW");
cars.add("Ford");
cars.add("Mazda");
Collections.sort(cars);
for (String i : cars) {
    System.out.println(i);
}

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.90
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "Java ArrayList" page (Astra wiki-curation, P-Reinforce v3.1 format).