📘 Lesson · Lesson 30
final, finally, finalize
final, finally, finalize
Three Similar-Sounding Words
These three sound alike but are completely different.
Comparison
| Keyword | Meaning |
|---|---|
| final | constant variable / no override / no inherit |
| finally | block that always runs after try-catch |
| finalize() | method called before garbage collection |
Examples
final int MAX = 100; // cannot change
try {
int x = 10 / 0;
} catch (Exception e) {
System.out.println("Error");
} finally {
System.out.println("Always runs");
}
Summary
- final = constant/no override; finally = always-run block; finalize = before GC.
तीन मिलते-जुलते शब्द
ये तीनों एक जैसे लगते हैं पर बिल्कुल अलग हैं।
तुलना
| Keyword | मतलब |
|---|---|
| final | constant variable / no override / no inherit |
| finally | try-catch के बाद हमेशा चलने वाला block |
| finalize() | garbage collection से पहले called method |
Examples
final int MAX = 100; // बदल नहीं सकते
try {
int x = 10 / 0;
} catch (Exception e) {
System.out.println("Error");
} finally {
System.out.println("Always runs");
}
सारांश
- final = constant/no override; finally = हमेशा चलने वाला block; finalize = GC से पहले।