STATIC
IF WE ARE developing a libraray managment system..
we have to give school name as static
class Student {
string name;
int roll no
static school name}
so if we create 100 instance(students) ..it is a shared variable...all the insatnaces refers to the class..
static doesnot work inside a function in java..because it is local variable cannot be refernced
using a constroctor..is not economicall
so we create a static block
we have to give school name as static
class Student {
string name;
int roll no
static school name}
so if we create 100 instance(students) ..it is a shared variable...all the insatnaces refers to the class..
static doesnot work inside a function in java..because it is local variable cannot be refernced
using a constroctor..is not economicall
so we create a static block
Comments
Post a Comment