Files
2nd/10_Wiki/Dev/Topic_Java/Java_Constructors.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.6 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-constructors Java Constructors Programming_Language draft conceptual
자바 생성자
B 0.9 2026-07-04 2026-07-04
java
programming
w3schools
oop
constructors
https://www.w3schools.com/java/java_constructors.asp

Java Constructors

🎯 한 줄 통찰 (One-line insight)

Every class gets a constructor whether you write one or not — if you don't declare one, Java silently generates a default one, but that hidden default can't set custom initial values, which is the practical reason to write your own. [S1]

🧠 핵심 개념 (Core concepts)

  • Constructor — a special method that initializes an object; runs automatically when an object is created. [S1]
  • Naming rule — the constructor's name must match the class name exactly. [S1]
  • No return type — a constructor cannot declare a return type, not even void. [S1]
  • Implicit default constructor — Java auto-generates one if none is written, but it can't set custom initial values. [S1]
  • Constructor parameters — like methods, constructors can take parameters used to set initial attribute values. [S1]

📖 세부 내용 (Details)

  • Basic constructor: public class Main { int x; public Main() { x = 5; } public static void main(String[] args) { Main myObj = new Main(); System.out.println(myObj.x); } } // Outputs 5. [S1]
  • Constructor with one parameter: public Main(int y) { x = y; } ... new Main(5); // x = 5. [S1]
  • Constructor with multiple parameters: public Main(int year, String name) { modelYear = year; modelName = name; } ... new Main(1969, "Mustang"); // "1969 Mustang". [S1]

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

  • 기본 생성자의 한계: 명시적으로 생성자를 작성하지 않으면 Java가 자동 생성하지만, 이 경우 초기값을 커스터마이즈할 수 없다는 점이 강조됨. [S1]

🛠️ 적용 사례 (Applied in summary)

현재 발견된 실제 적용 사례가 없습니다 — 자동차 모델(연도+이름)처럼 여러 초기값을 한 번에 설정하는 표준 패턴이다. [S1]

💻 코드 패턴 (Code patterns)

Constructor with multiple parameters (Java):

public class Main {
    int modelYear;
    String modelName;
    public Main(int year, String name) {
        modelYear = year;
        modelName = name;
    }
    public static void main(String[] args) {
        Main myCar = new Main(1969, "Mustang");
        System.out.println(myCar.modelYear + " " + myCar.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 Constructors" page (Astra wiki-curation, P-Reinforce v3.1 format).