Static members in Java - video 4.3 - Oracle Certified Associate Java Programmer Study

preview_player
Показать описание
Oracle Certified Associate programmer Certification IZ0-808 Chapter 4, video 3. This video details the principles of Java static members and how and why they should be used is explained.

In Java, static members are used in three basic contexts: -

1. To provide an entry point into a program without requiring an instance of the class (by using amain method).

2. For utility or helper methods that don’t require any object state. Since there is no need to access instance variables, unnecessary object creation is avoided.

3. For state that is shared by all instances of a class, like a counter on websites. All instances must share the same state for these members.

By walking through a set of test demonstration classes, the declaration, design, implementation and usage of static methods and variables is demonstrated in test classes. This includes comparing and contrasting static members with non-static members and demonstrating interaction and access rules between them.
Рекомендации по теме
join shbcf.ru