📘 Lesson  ·  Lesson 30

final, finally, finalize

final, finally, finalize

Three Similar-Sounding Words

These three sound alike but are completely different.

Comparison

KeywordMeaning
finalconstant variable / no override / no inherit
finallyblock 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मतलब
finalconstant variable / no override / no inherit
finallytry-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 से पहले।
← Back to Java Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

\n