--- id: java-else-if title: "Java Else If" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["else if statement", "μžλ°” else if"] 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", "conditions", "else-if"] raw_sources: ["https://www.w3schools.com/java/java_conditions_elseif.asp"] applied_in: [] github_commit: "" --- # [[Java Else If]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) An `else if` chain short-circuits at the first true condition β€” later conditions are never even evaluated, so ordering matters (e.g., a `time < 18` check placed before a `time < 12` check would incorrectly swallow morning cases). [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`else if`** β€” tests a new condition only if the preceding if/else-if was false. [S1] - **Syntax** β€” `if (condition1) {...} else if (condition2) {...} else {...}`. [S1] - **Chain evaluation** β€” conditions are checked top-to-bottom; the first true one wins and the rest are skipped. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Weather example: `int weather = 2; if (weather == 1) {...} else if (weather == 2) { System.out.println("Wear sunglasses."); } else {...} // Outputs "Wear sunglasses."`. [S1] - Time-of-day chain: `int time = 16; if (time < 12) {...} else if (time < 18) { System.out.println("Good day."); } else {...} // Outputs "Good day."`. [S1] - Falls through to final else: `int time = 22;` with the same chain outputs `"Good evening."` since neither earlier condition matches. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” μ…‹ μ΄μƒμ˜ λΆ„κΈ°κ°€ ν•„μš”ν•œ 닀쀑 쑰건 νŒλ‹¨(μ‹œκ°„λŒ€, μ˜¨λ„, λ“±κΈ‰ λ“±)의 ν‘œμ€€ νŒ¨ν„΄μ΄λ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Three-way branch chain (Java): ```java int time = 16; if (time < 12) { System.out.println("Good morning."); } else if (time < 18) { System.out.println("Good day."); } else { System.out.println("Good evening."); } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[Java Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[Java Else]], [[Java If Shorthand]], [[Java Switch]] - **μ°Έμ‘° λ§₯락:** 닀쀑 쑰건 λΆ„κΈ° β€” switch문의 λŒ€μ•ˆμœΌλ‘œ μ“°μž„. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” Java Else If β€” https://www.w3schools.com/java/java_conditions_elseif.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "Java Else If" page (Astra wiki-curation, P-Reinforce v3.1 format).