Post a Reply
|Oldest Newest Rating|
· February 3, 2015
Static means that you don't need to instantiate, or create, and object of the class to access the method, or function.
If you have a public static method, a class called, say Pie, can access a class called, say Fruit, and use it's method, say apples.
So you simply call
within a code block and it's completely valid. However, if the method is not static, you must create an object of the class, and the process takes longer, but is usually more proper way of doing things.
The reason it's cleaner is because you get access to things you didn't previously have access to. Such as, non-static variables and methods. Also, when you're editing a variable of apple, it's not going to impose a long-term effect to that code. i.e
There you aren't editing the "same" variable. Of course the variable seems the same, but in reality, you have 2 different instances of this variable. Whereas:
Above, you had the same intention as with the non-static approach, except you've gone and edited the same variable.
I hope this made sense, it's a fairly rough explanation.
· February 11, 2015
Simply, if you have a Static method or a member variable, That method or variable is exist one per JVM. It lives standalone to the class existence.
Java / Android Development
Very popular language used to create desktop applications, website applets, and Android apps.
|Bucky Roberts Administrator|