static keyword in java | static block | static method |

Опубликовано: 15 Ноябрь 2023
на канале: LearningPointAabid
37
8

In Java, the static keyword is used to define a class-level (or static) member. This means that the member belongs to the class rather than to any instance of the class.
Static keyword is non access modifiers
Static keyword use for class level variable
Static keyword use for method
Static is use for block level
Static is use for inner Class /nested class


There are several contexts in which the static keyword is used:

Static Variables (Class Variables): When a variable is declared with the static keyword, it becomes a class variable. There is only one copy of this variable that is shared among all instances of the class. Changes made to the variable will affect all instances of the class

Static Methods: When a method is declared with the static keyword, it becomes a class method. This means that the method can be called on the class itself rather than on an instance of the class. Static methods cannot access non-static (instance) variables directly.

Static Blocks: A static block is a block of code enclosed in curly braces and preceded by the static keyword. we declare static blocks when we want to initialize static fields in our class. Static blocks gets executed exactly once when the class is loaded .
Static blocks are executed even before the constructors are executed..

Static Nested Classes: A static nested class is a nested class that is declared with the static modifier. It can be accessed using the class name without creating an instance of the outer class.

The static keyword simplifies memory management and allows you to use members without creating an instance of the class. However, it's important to use it judiciously, as overuse of static members can lead to issues related to maintainability and testability in object-oriented design

source code link :-https://drive.google.com/file/d/14rwj...
previous video link :-   • object Array passing | object array return...  


На этой странице сайта вы можете посмотреть видео онлайн static keyword in java | static block | static method | длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь LearningPointAabid 15 Ноябрь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 37 раз и оно понравилось 8 зрителям. Приятного просмотра!