- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfinal.java
More file actions
Latest commit
22 lines (18 loc) · 470 Bytes
/
Copy pathfinal.java
File metadata and controls
22 lines (18 loc) · 470 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
classFinalDemo {
// Final variable (constant)
publicstaticfinaldoublePI = 3.14159;
// Final method (cannot be overridden)
publicfinalvoidshowInfo() {
System.out.println("PI value: " + PI);
}
}
classFinalChildextendsFinalDemo {
// Can't override showInfo() because it's final
// public void showInfo() { ... }
}
publicclassfinal{
publicstaticvoidmain(String[] args) {
FinalDemoobj = newFinalDemo();
obj.showInfo();
}
}