Was just wondering about the Static identifier. was wondering, how it works, what it does, and when i should use it. not really sure about this. ive used them, but only cause i was told too. not sure what exactly is the difference, and when or why i should be using them. maybe someone can explain to me.
The definition and use will vary depending on who you ask.
Static methods make no use of any of the environment they are defined in (including instance variables). They are mainly used for generic calculations via passing parameters to them.
You can call a static method without actually creating an explicit instance of the object.
so all they do is calculations really, they dont use any other methods or anything liek that, is that wha u mean, cause im not really sure i understand u? can u elaberate?
thnks again.
-keko-
also, buntine, how long have u been doin java, and how long did it take u to get good art it? is it worht to get into a career?
Two other uses of 'static' come to mind. Applying 'static' to a variable makes it a "class variable" which exists only once in memory and is shared and visible to all instances (objects) of the class containing it.
A static block at the top level of a class will be executed once by the class loader as the class is loaded. This is generally used to initialize class variables used like constants in an application.
In Java, normally methods are called in connection with a particular
class object, and operate upon that object. But static methods are
different; they are called in connection with no particular class object,
and usually operate upon all instances of the class (or upon the
environment that the class operates within).
also, buntine, how long have u been doin java, and how long did it take u to get good art it? is it worht to get into a career.
I have been using Java for about 1.5 years. It took a good six months for me to get a good idea of what was goingon. Im not a Java expert at all, though, have gained a firm knowledge of the core language.
There is alot of jobs around (mostly in the cities, depending on your area).
Bookmarks