docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
---
|
||||
id: java-arraylist
|
||||
title: "Java ArrayList"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["자바 ArrayList"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["java", "programming", "w3schools", "collections-framework", "arraylist"]
|
||||
raw_sources: ["https://www.w3schools.com/java/java_arraylist.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[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 methods** — `add()`, `add(index, value)` (insert at position), `get()`, `set()`, `remove()`, `clear()`, `size()`. [S1]
|
||||
- **Wrapper classes required for primitives** — `Integer` 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 ArrayList** — `List<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):
|
||||
```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)
|
||||
- **상위/루트:** [[Java Tutorial]]
|
||||
- **관련 개념:** [[Java List]], [[Java LinkedList]], [[Java Sort List]], [[Java Var Keyword]]
|
||||
- **참조 맥락:** List 인터페이스의 대표 구현체 — LinkedList와의 비교 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Java ArrayList — https://www.w3schools.com/java/java_arraylist.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Java ArrayList" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user