UNIT I (Static Keyword)
UNIT I (Static Keyword)
(PART-II)
JAVA ANATOMY
TOPICS:
JAVA Objects and References
Constructors
this Keyword
Arrays
Strings and Immutability
Buffer and Builder Classes
String Tokenizer
STATIC KEYWORD
Definition : The static keyword in Java
is used for memory management
mainly.
We can apply java static keyword with
variables, methods, blocks and nested
class.
The static keyword belongs to the
class than an instance of the class.
The static can be:
1. Variable (also known as a class variable)
2. Method (also known as a class method)
3. Block
4. Nested class
1.Java Static Variable: If you declare any
variable as static, it is known as a
static variable.
The static variable can be used to refer
to the common property of all objects
(which is not unique for each object).
for example, the company name of
employees, college name of students,
etc.
The static variable gets memory only
once in the class area at the time of
class loading.
Advantages :
1. It saves Memory.
2. Java Static Property is shared to all
Objects