1cfd3bbb56
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
3.5 KiB
3.5 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-var-keyword | Java Var Keyword | Programming_Language | draft | conceptual |
|
B | 0.88 | 2026-07-04 | 2026-07-04 |
|
|
Java Var Keyword
🎯 한 줄 통찰 (One-line insight)
var (Java 10+) is type INFERENCE, not dynamic typing — the compiler still locks in a fixed type at the moment of assignment (var x = 5; → permanently int), so x = 9.99; later still errors exactly as if you'd written int x = 5; explicitly. [S1]
🧠 핵심 개념 (Core concepts)
var(Java 10, 2018) — lets the compiler infer a variable's type from its assigned value. [S1]- Must assign at declaration —
var x;alone is an error;var x = 5;is required. [S1] - Type still locked in — once inferred, the type cannot change, exactly like an explicit declaration. [S1]
- Best for complex types — most useful for verbose generic types like
ArrayList<String>, less useful for simple types where explicit typing is already clear. [S1]
🧩 추출된 패턴 (Extracted patterns)
- var is sugar, not a type system change — it removes REPETITION (
ArrayList<String> cars = new ArrayList<String>();→var cars = new ArrayList<String>();) without weakening static type safety at all. [S1]
📖 세부 내용 (Details)
- Basic inference:
var x = 5; // x is an int. [S1] - Multiple types inferred:
var myNum = 5; var myDouble = 9.98; var myChar = 'D'; var myBoolean = true; var myString = "Hello";. [S1] - Must assign immediately:
var x; // Errorvs.var x = 5; // OK. [S1] - Type stays locked:
var x = 5; x = 10; // OK; x = 9.99; // Error. [S1] - Reduces verbosity for complex types:
var cars = new ArrayList<String>();instead ofArrayList<String> cars = new ArrayList<String>();. [S1]
⚖️ 모순 및 업데이트 (Contradictions & updates)
소스에서 모순되는 정보는 발견되지 않음.
🛠️ 적용 사례 (Applied in summary)
현재 발견된 실제 적용 사례가 없습니다 — ArrayList/HashMap처럼 제네릭 타입이 장황할 때 코드 가독성을 높이는 데 쓰인다. [S1]
💻 코드 패턴 (Code patterns)
var reduces verbosity for generic types (Java):
// Without var
ArrayList<String> cars = new ArrayList<String>();
// With var
var cars = new ArrayList<String>();
✅ 검증 상태 및 신뢰도
- 상태: draft
- 검증 단계: conceptual
- 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
- 신뢰 점수: 0.88
- 중복 검사 결과: 신규 생성 (New discovery)
🔗 지식 그래프 (Knowledge Graph)
- 상위/루트: Java Tutorial
- 관련 개념: Java Variables, Java ArrayList, Java Data Types
- 참조 맥락: 타입 추론으로 코드 간결화 — 여전히 정적 타이핑 안전성은 유지된다.
📚 출처 (Sources)
- [S1] W3Schools — Java var Keyword — https://www.w3schools.com/java/java_var.asp
📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "Java var Keyword" page (Astra wiki-curation, P-Reinforce v3.1 format).