Files
2nd/10_Wiki/Dev/Topic_Java/Java_This_Keyword.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

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-this-keyword Java This Keyword Programming_Language draft conceptual
this keyword
자바 this
B 0.9 2026-07-04 2026-07-04
java
programming
w3schools
oop
this
https://www.w3schools.com/java/java_this.asp

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):

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)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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