-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnnotations.java
More file actions
42 lines (36 loc) · 1.27 KB
/
Annotations.java
File metadata and controls
42 lines (36 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Annotations is used to provide extra information about a program.
//! Annotations provides metadata to class/methods.
//! Annotations starts with a '@'.
//! Annotations are helpful for detecting errors. Example : @override annotations will make sure that there are no typos while overriding a method.
@FunctionalInterface // * Used to ensure an interface is a functional interface
interface myFunctionalInterface {
void thisMethod();
}
class CellPhone {
public void ring() {
System.out.println("CellPhone Ringing!");
}
public void vibrate() {
System.out.println("CellPhone Vibrating!");
}
}
class SmartPhone extends CellPhone {
@Override // * This is used to mark override elements in the child class
public void ring() {
System.out.println("SmartPhone Ringing!");
}
@Deprecated // * This annotations is used to mark deprecated method
public int sum(int a, int b) {
return a + b;
}
}
public class Annotations {
@SuppressWarnings("warnings!") // * Used to suppress the generated warnings by the compilers
public static void main(String[] args) {
// ? Create the instance of the SmartPhone
SmartPhone sp = new SmartPhone();
sp.ring();
sp.vibrate();
sp.sum(5, 8);
}
}