dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: a question

  1. #1
    Join Date
    Aug 2004
    Posts
    61

    a question

    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.

    thnks
    -keko-

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    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.

    Regards.

  3. #3
    Join Date
    Aug 2004
    Posts
    61
    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?

  4. #4
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    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.

  5. #5
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    can u elaberate?
    Here is a nice little explanation I found:
    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).
    And here is a related article: http://www.developer.com/java/other/article.php/1025601
    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).

    Regards.

  6. #6
    Join Date
    Aug 2004
    Posts
    61
    thnks a lot guys, i appreciate the help

    -keko-

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles