반응형
Questions and Exercises: Annotations
Questions
What is wrong with the following interface?
public interface House { @Deprecated void open(); void openFrontDoor(); void openBackDoor(); }Consider this implementation of the
Houseinterface, shown in Question 1.public class MyHouse implements House { public void open() {} public void openFrontDoor() {} public void openBackDoor() {} }If you compile this program, the compiler produces a warning because
openwas deprecated (in the interface). What can you do to get rid of that warning?Will the following code compile without error? Why or why not?
public @interface Meal { ... } @Meal("breakfast", mainDish="cereal") @Meal("lunch", mainDish="pizza") @Meal("dinner", mainDish="salad") public void evaluateDiet() { ... }
Exercises
- Define an annotation type for an enhancement request with elements
id,synopsis,engineer, anddate. Specify the default value asunassignedfor engineer andunknownfor date.
«
DopZaClub
»
반응형
'Java 배우기' 카테고리의 다른 글
| Interfaces 인터페이스 (0) | 2016.01.05 |
|---|---|
| Lesson: Interfaces and Inheritance 단원: 인터페이스와 상속 (0) | 2016.01.05 |
| Repeating Annotations (0) | 2016.01.05 |
| Type Annotations and Pluggable Type Systems (0) | 2016.01.05 |
| Predefined Annotation Types 미리 정의된 어노테이션 타입들 (0) | 2016.01.05 |
댓글