I want u to note that what ever i write or explain is purely on practical playground or based on personnel experience or
practically implementation by me
so in this post ill be telling about static key word i just practiced it recently
so what does it do if u make a data type static(eg-static int;) then it is allocated memory globally
globally means that u can use it in any of your function of that class
we can also make a function static(static function())
now a static function has some properties like
1- only static datatypes or variables can be used in it
2- it is called using class name
it would be more clear with an example
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
class astatic{
static void bstatic (int a, int b,int c){
c=a+b;
System.out.println(""+c);
}}
class cstatic{
public static void main(String arg[]){
astatic.bstatic(2,3,0);
}
}
the variables declared in static are automatically initialised as static
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
2--now lets use static datamembers in other class as this one does
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
class astatic{
static int d=2,e=1,f=0;
static void bstatic (int a, int b,int c){
c=a+b;
System.out.println(""+c);
}
void dstatic( ){
f=d+e;
System.out.println(""+f);
}
}
class cstatic{
public static void main(String arg[]){
astatic.bstatic(2,3,0);
astatic object=new astatic();
object.dstatic();
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
practically implementation by me
so in this post ill be telling about static key word i just practiced it recently
so what does it do if u make a data type static(eg-static int;) then it is allocated memory globally
globally means that u can use it in any of your function of that class
we can also make a function static(static function())
now a static function has some properties like
1- only static datatypes or variables can be used in it
2- it is called using class name
it would be more clear with an example
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
class astatic{
static void bstatic (int a, int b,int c){
c=a+b;
System.out.println(""+c);
}}
class cstatic{
public static void main(String arg[]){
astatic.bstatic(2,3,0);
}
}
the variables declared in static are automatically initialised as static
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
2--now lets use static datamembers in other class as this one does
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
class astatic{
static int d=2,e=1,f=0;
static void bstatic (int a, int b,int c){
c=a+b;
System.out.println(""+c);
}
void dstatic( ){
f=d+e;
System.out.println(""+f);
}
}
class cstatic{
public static void main(String arg[]){
astatic.bstatic(2,3,0);
astatic object=new astatic();
object.dstatic();
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
No comments:
Post a Comment