In this course, you'll learn how annotations are defined and used in Java. You'll explore three popular built-in annotations, the @Override, @Deprecated, and @SuppressWarnings built-in annotations. Next, you'll examine how the @Override annotation is a valuable aid in detecting and fixing typos in the names of overridden methods, and crucially, helps to detect such issues at compile-time rather than at run-time. Then you'll explore the @Deprecated annotation and see how if you mark a class, method, or variable with the @Deprecated annotation, Java will issue an appropriate warning when you reference that element. You'll also learn about the @SuppressWarnings annotation, which does exactly what its name suggests, and for that reason ought to be used only with extreme caution, if at all. The @SuppressWarnings annotation allows the selective suppression of different types of warnings. You can also entirely eliminate all compiler warnings using @SuppressWarnings annotation with the "all" input argument, but this is quite dangerous and is an especially egregious programming practice.
Objectives |
---|
Advanced Features in Java: Using Built-in Annotations
|
