μλ°μ μ΄λ
Έν
μ΄μ
(Annotation)μ μμ€ μ½λμ λ©νλ°μ΄ν°λ₯Ό μΆκ°νλ λ°©λ²μ
λλ€. μ΄λ
Έν
μ΄μ
μ μ£Όλ‘ μ»΄νμΌλ¬μκ² μ 보λ₯Ό μ λ¬νκ±°λ λ°νμ μμ νλ‘κ·Έλ¨μ λμμ μμ νλ λ° μ¬μ©λ©λλ€. μ΄λ
Έν
μ΄μ
μ @ κΈ°νΈλ₯Ό μ¬μ©νμ¬ ννλλ©°, μ¬λ¬ μ’
λ₯κ° μμ΅λλ€.
λ©νλ°μ΄ν°?
μλ°μ μ΄λ Έν μ΄μ (Annotation)μμμ λ©νλ°μ΄ν°λ μμ€ μ½λμ λΆκ°μ μΈ μ 보λ₯Ό 첨λΆνμ¬ μ»΄νμΌλ¬, νλ μμν¬, λ°νμ νκ²½ λ±μ΄ ν΄λΉ μ 보λ₯Ό μ΄ν΄νκ³ νμ©ν μ μλλ‘ ν©λλ€. μ΄λ Έν μ΄μ μ μ£Όλ‘ ν΄λμ€, λ©μλ, νλ λ±μ μμμ λΆκ° μ 보λ₯Ό λΆμ¬νλ λ° μ¬μ©λ©λλ€.
1) @Override μ΄λ Έν μ΄μ : μ»΄νμΌλ¬μκ² ν΄λΉ λ©μλκ° λΆλͺ¨ ν΄λμ€μ λ©μλλ₯Ό μ€λ²λΌμ΄λνλ€λ μ 보λ₯Ό μ 곡
2) @Deprecated: ν΄λΉ μμ(ν΄λμ€, λ©μλ, νλ λ±)κ° λ μ΄μ κΆμ₯λμ§ μκ±°λ μ¬μ©λμ§ μμμ νμ
3) @SuppressWarnings: νΉμ κ²½κ³ λ₯Ό 무μνλλ‘ μ§μνλλ° μ¬μ©
4) @FunctionalInterface: ν¨μν μΈν°νμ΄μ€λ₯Ό λνλ λλ€. ν¨μν μΈν°νμ΄μ€λ νλμ μΆμ λ©μλλ§μ κ°μ§κ³ μλ μΈν°νμ΄μ€
5) @CustomAnnotation: μ¬μ©μκ° μ§μ μ μν 컀μ€ν μ΄λ Έν μ΄μ
μ΄μΈμλ μ¬λ¬ κ°μ§ μ΄λ Έν μ΄μ μ΄ μμΌλ©°, νλ μμν¬λ λΌμ΄λΈλ¬λ¦¬μμλ λ€μν μ΄λ Έν μ΄μ μ μ 곡ν©λλ€. μ΄λ Έν μ΄μ μ 리νλ μ (reflection)μ ν΅ν΄ λ°νμ μμ ν΄λΉ μ 보λ₯Ό μ½μ΄μ¬ μ μμ΄μ μ μ©νκ² νμ©λ©λλ€.
Annotations in Java provide additional information to the compiler and JVM. An annotation is a tag representing metadata about classes, interfaces, variables, methods, or fields.
Metadata refers to data that provides information about other data that enhances the understanding, management, and utilization of the underlying data.
'Programming > Java' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
25 Generics (1) | 2024.01.21 |
---|---|
24 Enum (0) | 2024.01.21 |
22 throw & throws (0) | 2024.01.21 |
21 Exception handling (0) | 2024.01.21 |
20 Exceptions (0) | 2024.01.21 |
λκΈ