Overriding

Overriding(μ˜€λ²„λΌμ΄λ”©) μƒμœ„ν΄λž˜μŠ€μ— μ •μ˜λœ λ©”μ„œλ“œμ˜ κ΅¬ν˜„ λ‚΄μš©μ΄ ν•˜μœ„ ν΄λž˜μŠ€μ—μ„œ κ΅¬ν˜„ν•  λ‚΄μš©κ³Ό λ§žμ§€ μ•Šμ„ 경우 ν•˜μœ„ν΄λž˜μŠ€μ—μ„œ λ™μΌν•œ μ΄λ¦„μ˜ λ©”μ„œλ“œλ₯Ό μž¬μ •μ˜ @overriding annotation = μž¬μ •μ˜λœ λ©”μ„œλ“œ ex) Customer.java public class Customer { protected String customerName; protected String customerGrade; int bonusPoint; double bonusRatio; //포인트 적립λ₯  public Customer(String customerName) { this.customerName = customerName; customerGrade =... Continue reading...

super

μ°Έμ‘°λ³€μˆ˜ super 객체 μžμ‹ μ„ κ°€λ¦¬ν‚€λŠ” μ°Έμ‘°λ³€μˆ˜ λΆ€λͺ¨ 클래슀 멀버와 μžμ‹ 클래슀 멀버 이름이 같을 λ•Œ super ν‚€μ›Œλ“œ μ‚¬μš©ν•΄ ꡬ별 μΈμŠ€ν„΄μŠ€ λ©”μ„œλ“œμ—μ„œλ§Œ μ‚¬μš© κ°€λŠ₯ (클래슀 λ©”μ„œλ“œμ—μ„œ μ‚¬μš© X) μƒμ„±μž super() λΆ€λͺ¨ 클래슀의 μƒμ„±μžλ₯Ό ν˜ΈμΆœν•  λ•Œ μ‚¬μš© λΆ€λͺ¨ 클래슀의 멀버λ₯Ό μ΄ˆκΈ°ν™”ν•˜κΈ° μœ„ν•΄μ„œλŠ” μžμ‹ 클래슀의 μƒμ„±μžμ—μ„œ λΆ€λͺ¨ 클래슀의 μƒμ„±μžκΉŒμ§€ ν˜ΈμΆœν•΄μ•Όν•¨ > λΆ€λͺ¨ν΄λž˜μŠ€μ˜ μƒμ„±μžλ₯Ό... Continue reading...

상속

이미 κ΅¬ν˜„λœ 클래슀λ₯Ό 상속(inheritance) λ°›μ•„ μ†μ„±μ΄λ‚˜ κΈ°λŠ₯을 ν™•μž₯ν•˜μ—¬ 클래슀λ₯Ό κ΅¬ν˜„ 이미 κ΅¬ν˜„λœ ν΄λž˜μŠ€λ³΄λ‹€ 더 ꡬ체적인 κΈ°λŠ₯을 가진 클래슀λ₯Ό κ΅¬ν˜„ν•΄μ•Ό ν•  λ•Œ κΈ°μ‘΄ 클래슀 상속 class B extends A{} : Bν΄λž˜μŠ€κ°€ A클래슀λ₯Ό μƒμ†λ°›μŒ 단일 상속(single inheritance) : extends ν‚€μ›Œλ“œ λ’€μ—λŠ” 단 ν•˜λ‚˜μ˜ 클래슀만이 올 수 있음 μƒμœ„ ν΄λž˜μŠ€λŠ” ν•˜μœ„ ν΄λž˜μŠ€λ³΄λ‹€ 더... Continue reading...

[Quiz] A-Z κΉŒμ§€ 배열에 μ €μž₯ν•˜κ³  10κ°œμ”© λŠμ–΄ 좜λ ₯ν•˜κΈ°

A-Z κΉŒμ§€ 배열에 μ €μž₯ν•˜κ³  10κ°œμ”© λŠμ–΄ 좜λ ₯ν•˜κΈ° public class ArrayQuiz { public static void main(String[] args) { char[] alphabets = new char[26]; char ch = 'A'; int count = 0; for (int i = 0; i < alphabets.length; i++) { alphabets[i] = ch++; count++; System.out.print(alphabets[i] +","+ (int)alphabets[i] + "\t"); if... Continue reading...

λ°°μ—΄

λ°°μ—΄ (Array) λ™μΌν•œ μžλ£Œν˜•μ˜ 순차적 자료 ꡬ쑰 λ°°μ—΄μ˜ μˆœμ„œλŠ” 0λΆ€ν„° μ‹œμž‘ 물리적 μœ„μΉ˜(λ©”λͺ¨λ¦¬ μ£Όμ†Œ)와 논리적 μˆœμ„œ(인덱슀) 동일 인덱슀([])λ₯Ό μ΄μš©ν•˜μ—¬ λΉ λ₯Έ μ°Έμ‘°(데이터 μ ‘κ·Ό) κ°€λŠ₯ λ°°μ—΄μ˜ μ„ μ–Έ : int[] arr = new int[10]; int arr[] = new int[10];도 κ°€λŠ₯ λ°°μ—΄μ˜ μ΄ˆκΈ°ν™” : μ„ μ–Έκ³Ό λ™μ‹œμ— μžλ£Œν˜•μ— 따라 μ •μˆ˜λŠ” 0, μ‹€μˆ˜λŠ” 0.0, κ°μ²΄λŠ” null둜... Continue reading...