Java Static variable, methods and static block

Veröffentlicht am: 20 November 2022
auf dem Kanal: Java Tutorial for Beginners
77
2

Java static keyword in java can be used to declare a variable, used to make a method static, and also to declare a static block. When static keyword is used, it means we can use the variable, method etc without creating instance of the class. We can use class name dot variable or method name to directly access it. Static variables are shared across all instances of that class and should be used when the variable state needs to be shared. Static block is executed when the class is loaded initially and should be used to initialize static variables. A static method can be called directly on the class and mostly used as a utility method which can be used even before the java objects are created. In rare cases, innner static classes can be created as well so keep the code more organized.


Auf dieser Seite können Sie das Online-Video Java Static variable, methods and static block mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Java Tutorial for Beginners 20 November 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 77 Mal angesehen und es wurde von 2 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!