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,76 @@
|
||||
---
|
||||
id: java-this-keyword
|
||||
title: "Java This Keyword"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["this keyword", "자바 this"]
|
||||
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", "oop", "this"]
|
||||
raw_sources: ["https://www.w3schools.com/java/java_this.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Java This Keyword]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Without `this`, writing `x = x;` inside a constructor whose parameter shadows the class field would silently assign the parameter to itself, leaving the actual class variable uninitialized at 0 — `this.x = x;` is the only way to disambiguate which `x` is meant when names collide. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`this`** — refers to the current object inside a method or constructor. [S1]
|
||||
- **Name-shadowing scenario** — when a parameter has the same name as a class attribute, the parameter temporarily hides the class variable within that scope. [S1]
|
||||
- **`this.x = x;`** — assigns the parameter's value to the class attribute, resolving the shadow. [S1]
|
||||
- **`this(...)`** — calls another constructor in the same class; must be the FIRST statement in the calling constructor. [S1]
|
||||
- **Constructor chaining use case** — providing default values or reusing initialization code instead of repeating it. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Shadow resolution: `public Main(int x) { this.x = x; }` — without `this`, `x = x;` would leave the class variable at its default 0. [S1]
|
||||
- Constructor chaining: `public Main(String modelName) { this(2020, modelName); } public Main(int modelYear, String modelName) { this.modelYear = modelYear; this.modelName = modelName; }` — calling `new Main("Corvette")` yields `2020 Corvette` via the default-year chain. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **this() 호출 위치 제약**: 생성자 내에서 this()를 호출할 경우 반드시 첫 번째 문장이어야 한다는 점이 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 기본값(2020년형)을 제공하는 생성자 체이닝은 초기화 코드 중복을 피하는 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Constructor chaining with this() for default values (Java):
|
||||
```java
|
||||
public class Main {
|
||||
int modelYear;
|
||||
String modelName;
|
||||
public Main(String modelName) {
|
||||
this(2020, modelName); // must be first statement
|
||||
}
|
||||
public Main(int modelYear, String modelName) {
|
||||
this.modelYear = modelYear;
|
||||
this.modelName = modelName;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Java Tutorial]]
|
||||
- **관련 개념:** [[Java Constructors]], [[Java Modifiers]]
|
||||
- **참조 맥락:** 이름 충돌 해소 및 생성자 체이닝 — Modifiers 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Java this — https://www.w3schools.com/java/java_this.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Java this Keyword" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user