Static variable initailization

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Black Java

    Static variable initailization

    Hi There,
    I'm new to Java. Having read a bunch of books, I wonder if static
    variable is initailized by defualt value? Textbooks only indicate that
    instance variable is implicitly initailized.

    Thanks in advance,
    Black Java
    (Student from city of angel)
  • Jonas Kongslund

    #2
    Re: Static variable initailization

    Black Java wrote:
    [color=blue]
    > Hi There,
    > I'm new to Java. Having read a bunch of books, I wonder if static
    > variable is initailized by defualt value? Textbooks only indicate that
    > instance variable is implicitly initailized.[/color]

    Static variables are actually called class variables in Java.

    Section 4.5.5 in the Java Language Specification, 2nd edition, states:
    "Each class variable, instance variable, or array component is initialized
    with a default value when it is created"

    See
    <http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc .html#96595>
    for more information.

    --
    Jonas Kongslund

    Comment

    • nos

      #3
      Re: Static variable initailization

      watch out because "local" variables are not initialized

      "Jonas Kongslund" <[email protected] t.all> wrote in message
      news:fwqtb.1102 5$HB.3598@news. get2net.dk...[color=blue]
      > Black Java wrote:
      >[color=green]
      > > Hi There,
      > > I'm new to Java. Having read a bunch of books, I wonder if static
      > > variable is initailized by defualt value? Textbooks only indicate that
      > > instance variable is implicitly initailized.[/color]
      >
      > Static variables are actually called class variables in Java.
      >
      > Section 4.5.5 in the Java Language Specification, 2nd edition, states:
      > "Each class variable, instance variable, or array component is[/color]
      initialized[color=blue]
      > with a default value when it is created"
      >
      > See
      >[/color]
      <http://java.sun.com/docs/books/jls/s...alues.doc.html
      #96595>[color=blue]
      > for more information.
      >
      > --
      > Jonas Kongslund[/color]


      Comment

      Working...