In every java programming language , A class can containing two types of Data Members .They are :
1.Non-static data members.
2.Static data member.
Instance Data Member
➢Instance data members memory space is created each every time whenever the object is created.
➢Instance data member are used for storing specific values which are suitable for individuals.
➢Instance data member declaration should not be preceded by 'Static keyword' .
Ex:- int a=10,20,30,40; (Instance Data Member)
➢Datatype V 1 ,V 2,V 3........V n ;.
➢Each & every instance data member must be access with respect to Object name
(Object . Instance Data Member Name)
➢Instance data member value are not shareable.
➢Instance data members are also called "Object level Data Members".Below following examples are the instance data type members.
EX : int student Id ;
String course;
String student name ;
float marks;
Static Data Members
➢ Static data members memory space is created once only when we defined the class then irrespective number of times objects are created.
➢ Static date members are used for storing common values which are suitable for all programmers.
➢ Static data members declaration is must be preceded by "static keyboard "
➢ Static" data type V 1,V 2.......V n ;
➢ Each & every data member must be access to respect to object even with class name (obj. class).
➢ Static data members are shareable
➢ Static data member are also called "class level data members ". Below following examples are the static data type members.
EX: static string course ;
static string Delhi ;
static string pi ;
NOTE:- Each every final variable must be static but a static variable value may are not be final .
static final float PI= 3.14f ;
static final String s="Java";
1.Non-static data members.
2.Static data member.
Instance Data Member
➢Instance data members memory space is created each every time whenever the object is created.
➢Instance data member are used for storing specific values which are suitable for individuals.
➢Instance data member declaration should not be preceded by 'Static keyword' .
Ex:- int a=10,20,30,40; (Instance Data Member)
➢Datatype V 1 ,V 2,V 3........V n ;.
➢Each & every instance data member must be access with respect to Object name
(Object . Instance Data Member Name)
➢Instance data member value are not shareable.
➢Instance data members are also called "Object level Data Members".Below following examples are the instance data type members.
EX : int student Id ;
String course;
String student name ;
float marks;
Static Data Members
➢ Static data members memory space is created once only when we defined the class then irrespective number of times objects are created.
➢ Static date members are used for storing common values which are suitable for all programmers.
➢ Static data members declaration is must be preceded by "static keyboard "
➢ Static" data type V 1,V 2.......V n ;
➢ Each & every data member must be access to respect to object even with class name (obj. class).
➢ Static data members are shareable
➢ Static data member are also called "class level data members ". Below following examples are the static data type members.
EX: static string course ;
static string Delhi ;
static string pi ;
NOTE:- Each every final variable must be static but a static variable value may are not be final .
static final float PI= 3.14f ;
static final String s="Java";