what is the basic purpose of static class/methode
-
Please tell me some details about
static class/methode
, i search for it on internet in forms etc but i didn't yet setisfied and still unable to explain it in confident and clear way :( the most common questions about static class/methode in my mind are, - why use static class My Knowledge >> They provide access to class static methode directly without creating its instance. they have same instance in memory .. means every use/access to this methode can have changes effect for every one. ANY OTHER BENEFIT AND PURPOSE !! Also please tell me clearly the basic purpose ofstatic
class/method ... in interviews they always as to me about it and i always failed to answer clearly to him :sigh: -
Please tell me some details about
static class/methode
, i search for it on internet in forms etc but i didn't yet setisfied and still unable to explain it in confident and clear way :( the most common questions about static class/methode in my mind are, - why use static class My Knowledge >> They provide access to class static methode directly without creating its instance. they have same instance in memory .. means every use/access to this methode can have changes effect for every one. ANY OTHER BENEFIT AND PURPOSE !! Also please tell me clearly the basic purpose ofstatic
class/method ... in interviews they always as to me about it and i always failed to answer clearly to him :sigh:Static can be used in various ways. Anything that needs to be shared across all instances of a class can either be made static - easy - or passed around in another object - hard. Certain design patterns - I'm thinking the singleton here - rely on static methods to encapsulate class functionality and control behaviour. Any method that does not (or must not) use instance data should be static to prevent it accessing the instance data. There is no need to instantiate an object to call a static method - say a helper class providing oft called methods - have a look at the static methods on
String
.
Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
-
Please tell me some details about
static class/methode
, i search for it on internet in forms etc but i didn't yet setisfied and still unable to explain it in confident and clear way :( the most common questions about static class/methode in my mind are, - why use static class My Knowledge >> They provide access to class static methode directly without creating its instance. they have same instance in memory .. means every use/access to this methode can have changes effect for every one. ANY OTHER BENEFIT AND PURPOSE !! Also please tell me clearly the basic purpose ofstatic
class/method ... in interviews they always as to me about it and i always failed to answer clearly to him :sigh: -
Please tell me some details about
static class/methode
, i search for it on internet in forms etc but i didn't yet setisfied and still unable to explain it in confident and clear way :( the most common questions about static class/methode in my mind are, - why use static class My Knowledge >> They provide access to class static methode directly without creating its instance. they have same instance in memory .. means every use/access to this methode can have changes effect for every one. ANY OTHER BENEFIT AND PURPOSE !! Also please tell me clearly the basic purpose ofstatic
class/method ... in interviews they always as to me about it and i always failed to answer clearly to him :sigh:Static methods are frequently used in several design patterns (Singleton, DataFactory...) but, to give you something very simple and easy to understand, think about Math class. How do yo use it?
a = Math.abs(n);
a = Math.floor(n);
a = Math.sqrt(n);
...So, as you can see, we don't have to create an instance of Math class, becouse we just use its static methods. In these cases, we say the Math class only offers services, and that is why all of its methods are static.
-
Static methods are frequently used in several design patterns (Singleton, DataFactory...) but, to give you something very simple and easy to understand, think about Math class. How do yo use it?
a = Math.abs(n);
a = Math.floor(n);
a = Math.sqrt(n);
...So, as you can see, we don't have to create an instance of Math class, becouse we just use its static methods. In these cases, we say the Math class only offers services, and that is why all of its methods are static.
Thanks for your help .... Thanks a lot
-
Static can be used in various ways. Anything that needs to be shared across all instances of a class can either be made static - easy - or passed around in another object - hard. Certain design patterns - I'm thinking the singleton here - rely on static methods to encapsulate class functionality and control behaviour. Any method that does not (or must not) use instance data should be static to prevent it accessing the instance data. There is no need to instantiate an object to call a static method - say a helper class providing oft called methods - have a look at the static methods on
String
.
Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
Thanks for your help .... Thanks a lot
-
Please tell me some details about
static class/methode
, i search for it on internet in forms etc but i didn't yet setisfied and still unable to explain it in confident and clear way :( the most common questions about static class/methode in my mind are, - why use static class My Knowledge >> They provide access to class static methode directly without creating its instance. they have same instance in memory .. means every use/access to this methode can have changes effect for every one. ANY OTHER BENEFIT AND PURPOSE !! Also please tell me clearly the basic purpose ofstatic
class/method ... in interviews they always as to me about it and i always failed to answer clearly to him :sigh:static can be declared for variables and methods. When instance variables declared as static then its called class variables. Local variable can not be static.Each and every object share the same variables. In the sense when one object modify the variable the result will be reflected in all objects. With out creating object static variable methods can be accessed.Before object creation static variables initialized or instantiated.