Lesson 30 of 34
static மற்றும் finalstatic and final
8 min 35 XP
static field எல்லா objects-க்கும் பொதுவானது, ஒரே ஒரு copy தான். உதாரணம்: எத்தனை objects உருவானது என்று எண்ணுதல். static method-ஐ object இல்லாமல் ClassName.method() என்று அழைக்கலாம். final மதிப்பை மாற்ற முடியாது.
A static field is shared by all objects, with just one copy, for example to count how many objects were created. Call a static method without an object as ClassName.method(). A final value can't be changed.
Example: edit me and press Run
Press Run to see the result here.main() ஏன் static? JVM ஒரு object உருவாக்காமலேயே அதை அழைக்க வேண்டும். இது ஒரு பிரபல interview கேள்வி.
Why is main() static? The JVM must call it before any object exists. A popular interview question.