Lesson 30 of 34
static और final
8 min 35 XP
static field सभी objects में साझा होता है, उसकी सिर्फ़ एक copy होती है, जैसे यह गिनने के लिए कि कितने objects बने। static method को object के बिना ClassName.method() से call करें। final value बदली नहीं जा सकती।
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.main() static क्यों है? क्योंकि JVM को उसे किसी भी object के बनने से पहले call करना होता है। Interview का लोकप्रिय सवाल।